When plotting heat maps matlab plots 80 different figures
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, guys ive been trying to plot 3 heat maps but for some reason that i cant understand matlab plots 80 different line plots
1 Commento
Stephen23
il 10 Dic 2021
Modificato: Stephen23
il 10 Dic 2021
Original question by Sebastion Sunny retrieved from Google Cache:
When plotting heat maps matlab plots 80 different figures instead of just 3
Hi, guys ive been trying to plot 3 heat maps but for some reason that i cant understand matlab plots 80 different line plots ive attacehd the code below with a pictur of the desireed heatmaps:
clear all
close
figure;
deltaT = 0.01;
time = 0:deltaT:300;
k=6*10.^(1:10);
Cd=1.5*10.^(1:8);
%preallocation
turbinePowerMean = zeros(length(k),length(Cd));
turbinePowerStd = zeros(length(k),length(Cd));
%------------------Do not edit these lines---------------------------------
windTimeSeries = wblrnd(13,2.10,size(time'));
windTimeSeries = medfilt1(windTimeSeries,50,'truncate');
%-------------------------------------------------------------------------
for i = 1:length(k)
for j = 1:length(Cd)
data = windTurbineModel(windTimeSeries,Cd(j),deltaT,time,k(i));
turbinePowerMean(j,i) = mean(data);
turbinePowerStd(j,i) = std(data);
end
end
Turbinepower = turbinePowerMean/7000;
TurbineSTD = turbinePowerStd/7000;
meanSTD = turbinePowerMean./turbinePowerStd;
%plotting
subplot (1,3,1)
h1 = heatmap(k,Cd,Turbinepower);
xlabel('Generator control gain, k')
ylabel('Damping coeff kg m^2 s^-1')
title('Mean Power Output for varying k and c' )
subplot(1,3,2)
h2 = heatmap(k,Cd,TurbineSTD);
xlabel('Generator control gain, k')
ylabel('Damping coeff kg m^2 s^-1')
title('std Power Output for varying k and c' )
subplot (1,3,3)
h3 = heatmap(k,Cd,meanSTD);
xlabel('Generator control gain, k')
ylabel('Damping coeff kg m^2 s^-1')
title('mean/std Output for varying k and c' )
functions:
function turbinePower = windTurbineModel(WindSpeeds,Cd,deltaT,time,k)
%vairables defined
Cp = 0.335;
Ct = 0.042;
Vrated = 11.5; %m/s
Vcutin = 3; %m/s
Vcutout = 25; %m/s
D = 171;
j = 100e5;
%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)
rotorTorque(i) = windTurbineRotorModel(WindSpeeds(i),Ct,D,Vcutout,Vrated,Vcutin);
omegaRotor(i) = omegaRotor(i-1)+deltaT*(rotorTorque(i)-generatorTorque(i-1)-(Cd*(omegaRotor(i-1))))/j;
turbinePower(i) = omegaRotor(i)*rotorTorque(i);
generatorTorque(i) = k * omegaRotor(i).^2;
end
figure;
plot(WindSpeeds,turbinePower/1000)
ylabel('TurbinePower kW')
hold on
yyaxis right
plot(WindSpeeds,generatorTorque/1000)
hold on
plot(WindSpeeds,rotorTorque/1000)
end
function 2:
function [rotorTorque] = windTurbineRotorModel(WindSpeeds,Ct,D,Vcutout,Vrated,Vcutin)
if (WindSpeeds < Vcutin)
rotorTorque = 0;
elseif all(WindSpeeds >Vcutin) && all(WindSpeeds <=Vrated)
rotorTorque = (Ct)*(1/2)*(1.23)*pi*((D/2)^3)*WindSpeeds^2;
elseif all(WindSpeeds >Vrated) && all(WindSpeeds <= Vcutout)
rotorTorque = (Ct)*(1/2)*(1.23)*pi*((D/2)^3)*Vrated^2;
else
rotorTorque = 0;
end
end
Thanks guys any help appreciated
Risposte (1)
Voss
il 9 Dic 2021
The function windTurbineModel creates a figure; you call windTurbineModel 80 times. Therefore, 80 figures are created via windTurbineModel.
2 Commenti
Rik
il 10 Dic 2021
@Sebastian Sunny Why did you edit away your questions? That way you remove most of the value of the answer, so the chances of someone else benefiting are much smaller. Why did you do that? This is considered very rude.
Vedere anche
Categorie
Scopri di più su Geodesy and Mapping in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!