Write a for loop from 1 to 3 usingi as the variable. For each value ofi:
Create a vector x of 10 random numbers between0 and 1. Create a second vector t which is equal to ten integersfrom 1 to 10. Plot x versus t infigure 1. Use hold on to keep each plot. Use adifferent color for the line for each value ofi.
At the very end, add the text 'time' usingxlabel to the horizontal axis, and the text'f(t)' using ylabel to thevertical axis.
This is what I have so far:
% Creating a 'for' loop from 1 to 3 using 'i' as thevariable
for i=1:3
% For each value of 'i', creating a vector 'x' of 10 random numbersbetween 0 and 1
x=rand(1,10);
% For each value of 'i', creating a second vector 't' which isequal to 10 integers from 1 to 10
t=randi([1,10],10);
end
% Plotting 'x' versus 't' in figure 1
figure(1),plot(x,t)
% Using 'hold on' to keep each plot
hold on
% Using a different color for the line for each value of'i'
%add code
% Adding the text 'time' using 'xlabel' to the horizontalaxis
xlabel('time')
% Adding the text 'f(t)' using 'ylabel' to the verticalaxis
ylabel('f(t)')