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

Write a Matlab script that creates an array of m=0, 0.5, 1, 1.5, 2, 2.5,3 and th

ID: 3635100 • Letter: W

Question

Write a Matlab script that creates an array of m=0, 0.5, 1, 1.5, 2, 2.5,3 and then uses a for loop to create an array n. The terms in n will be calculated in the following manner: If a term is not a whole number (the floor command rounds down a number, therefore if j=2.5, floor(j)=2), then the corresponding term in n will be twice the corresponding term in m, otherwise, the corresponding term in n will be equal to half the corresponding term in m. Your code should output the paired values of n & m in a table (as shown below).
m n
0 0
0.5 1
1 0.5
1.5 3
2 1
... ...

Explanation / Answer

count =0;

for m=0:0.5:10

if count%2==0

n = m/2;

else

n = 2*m;

end

count = count+1;

m n

end

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