Not sure whats wrong with the values in this plot
Show older comments
Hi guys, ive been stuck on this bit of code for awhile as im getting a empty plots, im not sure of what im doing wrong is to do with the actaul variables being wrong or is i ahve used the for loop vairale wrong.
7 Comments
Mathieu NOE
on 9 Dec 2021
hi
missing function windTurbineRotorModel
Walter Roberson
on 9 Dec 2021
plot(WindSpeeds,generatorTorque(i))
You are after the for i loop at that point, so i will have the scalar value that it was last assigned, which is length(time) . So you are asking to plot() with a vector on the x and a scalar for the y.
Sebastian Sunny
on 9 Dec 2021
Sebastian Sunny
on 9 Dec 2021
Walter Roberson
on 9 Dec 2021
if (WindSpeeds < Vcutin)
Is WindSpeeds a scalar or a vector? If it is a scalar, then that statement is okay. If it is a vector then the statement is questionable.
elseif all(WindSpeeds >Vcutin) && all(WindSpeeds <Vrated)
all those all() -- is WindSpeeds a vector or a scalar? If it is a scalar then if Vcutin is a vector then you have problems back in the if . If it is a scalar and Vcutin is a scalar then why confuse the reader by using all() ?
Be consistent in how you treat your inputs.
Sebastian Sunny
on 9 Dec 2021
Original question by Sebastion Sunny retrieved from Google Cache:
Not sure whats wrong with the values in this plot
Hi guys, ive been stuck on this bit of code for awhile as im getting a empty plots, im not sure of what im doing wrong is to do with the actaul variables being wrong or is i ahve used the for loop vairale wrong. I' ve attached a picture of what the graph should look like and the result im getting.

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
yyaxis left
plot(WindSpeeds,omegaRotor)
hold on
plot yy
yyaxis right
plot(WindSpeeds,generatorTorque(i))
hold on
yyaxis right
plot(WindSpeeds,rotorTorque)

Accepted Answer
More Answers (0)
Categories
Find more on Axes Transformations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!