MATLAB
Create a matrix E, using A and B vectors as row 1 and row 2 respectively
A = 10 thru 1
B = 1 thru 4.2 with ten equally spaced elements
and
Find the indices (row and col) within E where (prob02a, b, c, d)
E = 5
E > 4
E < 1.9
E > 1 and E < 2
A=10:-1:1;
B=linspace(1,4.2,10);
E=[A;B]
fprintf('E=5 indices\n')
for i=1:2
for j=1:10
if(E(i,j)==5)
fprintf('row =%d col=%d\n',i,j);
end
end
end
fprintf('\nE>4 indices\n')
for i=1:2
for j=1:10
if(E(i,j)>4)
fprintf('row =%d col=%d\n',i,j);
end
end
end
fprintf('\nE<1.9 indices\n')
for i=1:2
for j=1:10
if(E(i,j)<1.9)
fprintf('row =%d col=%d\n',i,j);
end
end
end
fprintf('\nE>1 and E<2 indices\n')
for i=1:2
for j=1:10
if(E(i,j)>1 && E(i,j)<2)
fprintf('row =%d col=%d\n',i,j);
end
end
end
Get Answers For Free
Most questions answered within 1 hours.