Azzera filtri
Azzera filtri

Struggling to plot this graph

1 visualizzazione (ultimi 30 giorni)
Sebastian Sunny
Sebastian Sunny il 5 Dic 2021
Modificato: Stephen23 il 10 Dic 2021
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 Commento
Stephen23
Stephen23 il 10 Dic 2021
Modificato: Stephen23 il 10 Dic 2021
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))

Accedi per commentare.

Risposta accettata

Voss
Voss il 5 Dic 2021
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.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by