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

clc

p=zeros(1,5)
i=[0 0.1 0.2 0.3 0.4 0.5];
v=[0 0.2 0.4 0.6 0.8 1.0];

for k=1:6
p(1,k)=v(1,k)*i(1,k);
end
subplot(2,1,1); plot(i,v)
title(\'Voltage vs Current\')
subplot(2,1,2); plot(i,p)
title(\'power vs Current\')

Note: in matlab i,v are taken as row matrices thats why you were not getting the result so the above program will help u

 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 wo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site