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

matlab code, I figured these out in Fortran but I am having trouble translating

ID: 3679350 • Letter: M

Question

matlab code, I figured these out in Fortran but I am having trouble translating it to a matlab code.

n is the number of elements, s is the initial value, f is the final value and d is the increment/decrement calculated as follows
d=(f-s)/(n-1)

a.) Create a rank-1 vector x with 100 equally spaced values from –3.25 to 10.

b.) Display the value of the first, second, last and the element right before the last one of the vector created in (a.)

c.) Create a new vector whose elements are the first, third, fifth, and seventh elements of the vector created in (a).

Explanation / Answer

a)

%n is the number of elements
n=100;
%s is the initial value
s=-3.25;
%f is the final value
f=10
%d is the increment/decrement
d=(f-s)/(n-1);

for x=s:d:f
    disp(x)
end
r=rank(x)
fprintf("The rank is%d",r)