
When plotting heat maps matlab plots 80 different figures
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Stephen23
2021 年 12 月 10 日
編集済み: Stephen23
2021 年 12 月 10 日
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

回答 (1 件)
Voss
2021 年 12 月 9 日
The function windTurbineModel creates a figure; you call windTurbineModel 80 times. Therefore, 80 figures are created via windTurbineModel.
2 件のコメント
Rik
2021 年 12 月 10 日
@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.
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!