A Matlab novice wants to plot two graphs each one in a diffe
A Matlab novice wants to plot two graphs each one in a different window. He came out with code shown below. He tried once and it did not work. Make the code work as it should. I = [0 0.1 0.2 0.3 0.4 0.5] %current v = [0 0.2 0.4 0.6 0.8 1.0] %voltage p = v*i %power plot(i, v) %plot current versus voltage plot(i, p) %plot current versus power
Solution
Correct Code
i = [0 0.1 0.2 0.3 0.4 0.5];
v= [0.2 0.4 0.6 0.8 1.0];
p = v.*i;
plot(i,v)
plot(i,p)
%% Comment : p and i vector should be of same size. for element wise multiplication correct syntax is ( p=v.*i ). (.) is necessary for element wise multiplication.
