When plotting heat maps matlab plots 80 different figures

조회 수: 1 (최근 30일)
Sebastian Sunny
Sebastian Sunny 2021년 12월 9일
댓글: Rik 2021년 12월 10일
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
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
Voss 2021년 12월 9일
The function windTurbineModel creates a figure; you call windTurbineModel 80 times. Therefore, 80 figures are created via windTurbineModel.
  댓글 수: 2
Sebastian Sunny
Sebastian Sunny 2021년 12월 9일
That makes more sense thank you
By any chance i'm also getting a error message saying numerber of y values must equal the number of rows in 'ColorData'
Thanks
Rik
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 CenterFile Exchange에서 Geodesy and Mapping에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by