Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this problem, you will create two vectors, alpha and beta, using two % differ

ID: 3831648 • Letter: I

Question

In this problem, you will create two vectors, alpha and beta, using two % different "for" loops as instructed below. Both vectors will run from 0 to pi in % pi/8 increments % % a) Use the "for" loop index to assign the values in alpha fprintf(' #la ') clear all alpha=zeros(1, 9); % your code goes here % % Display the results - given fprintf(' alpha = [%2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f] ', alpha) % % b) Use the "for" loop index to increments the array element number fprintf(' #lb ') clear all beta=zeros(1, 9); % your code goes here % % Display the results fprintf(' beta = [%2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f] ', beta) %

Explanation / Answer

fprintf(' #1a ')

clear all
alpha=zeros(1,9);
j=1;

for i=0:pi/8:pi
%using for loop index to assign values in alpha
alpha(j)=i;
j=j+1;
end


fprintf(' alpha=[%2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f] ',alpha);

------------------------------------------------------------------------

fprintf(' #1b ')

clear all;
beta=zeros(1,9);
j=1;
for i=0:pi/8:pi
%using for loop index to increment values in beta

beta(j)=beta(j)+i;
j=j+1;
end


fprintf(' beta=[%2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f] ',beta);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote