Struggling to plot this graph

1 次查看(过去 30 天)
Hi guys,
Im trying to plot 3 sets of data using this code with aswell as the 2 torques but i get a empty plot graph how would i fix this?
  1 个评论
Stephen23
Stephen23 2021-12-10
编辑:Stephen23 2021-12-10
Original question by Sebastian Sunny retrieved from Google Cache:
Struggling to plot this graph
Hi guys,
Im trying to plot 3 sets of data using this code with omegaRotor over windspeed aswell as the 2 torques but i get a empty plot graph how would i fix this?
%vairables defined
Cp = 0.335;
Ct = 0.042;
Vrated = 11.5; %m/s
Vcutin = 3; %m/s
Vcutout = 25; %m/s
D = 171;
k = 6e6;
j = 100e5;
%Create wind,time and rotational speed variables
WindSpeeds = linspace(0,30,30001);%m/s
deltaT = 0.01;
time = 0:deltaT:300;
%preallocation
rotorTorque = zeros(length(WindSpeeds),1); %Nm
turbinePower = zeros(length(WindSpeeds),1);
generatorTorque = zeros(length(WindSpeeds),1);
omegaRotor = zeros(length(WindSpeeds),1);
%eulers method
for i = 2:length(time)
omegaRotor(i) = omegaRotor(i-1) + deltaT*((windTurbineRotorModel(WindSpeeds(i),Ct,D,Vcutout,Vrated,Vcutin))-(k*omegaRotor(i-1).^2)/j);
generatorTorque(i) = k*(omegaRotor(i).^2);
rotorTorque(i) = windTurbineRotorModel(WindSpeeds(i),Ct,D,Vcutout,Vrated,Vcutin);
end
plot(WindSpeeds,omegaRotor(i))
plot(WindSpeeds,generatorTorque(i))
plot(Windspeeds,rotorTorque(i))

请先登录,再进行评论。

采纳的回答

Voss
Voss 2021-12-5
Remove the (i) indexing in your calls to plot. This will make plot create one line per call with all the time points rather than one line per data point with one point in each line.
Also, call hold on after the first call to plot so that subsequent calls to plot do not delete previous lines, which is the default behavior.
Also, in order to reproduce the plot in the image, you'll need to use plotyy or something similar to get multiple y-axes with different scales.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by