I am trying to make a graph with a function.
This is my graph ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/829195/image.png)
I need it to look like this graph ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/829200/image.png)
Here is my function
function [turbinePower] = windTurbineModel(windSpeed,deltaT,cD,k)
cTau = 0.042;
vRated = 11.5;
vCutin = 3;
vCutout = 25;
D = 171;
J = 100e5;
time = 0:deltaT:300;
rotationalSpeeds = zeros(length(windSpeed),1);
rotorTorque = zeros(length(windSpeed),1);
generatorTorque = zeros(length(windSpeed),1);
turbinePower = zeros(length(windSpeed),1);
rotorAcc = zeros(length(windSpeed),1);
for i = 2:length(time)
rotorTorque(i) = windTurbineRotorModel(windSpeed(i),cTau,D,vCutin,vCutout,vRated);
generatorTorque(i) = k*((rotationalSpeeds(i-1))^2);
rotorAcc(i) = (rotorTorque(i)-generatorTorque(i)-cD*rotationalSpeeds(i))/J;
rotationalSpeeds(i) = rotationalSpeeds(i-1) + deltaT*(rotorAcc(i))./J;
turbinePower(i) = generatorTorque(i)*rotationalSpeeds(i);
end
end
and here is my graph code
close all
clear
k=6*10.^(1:1:10);
Cd = 1.5*10.^(1:1:8);
deltaT = 0.01;
time = 0:deltaT:300;
turbinePowerMean = zeros(length(Cd),length(k));
turbinePowerStd = zeros(length(Cd),length(k));
windTimeSeries = wblrnd(13,2.10,size(time'));
windTimeSeries = medfilt1(windTimeSeries,50,'truncate');
for i = 1:length(k)
for ii = 1:length(Cd)
turbinePower = (windTurbineModel(windTimeSeries,deltaT,Cd(ii),k(i)));
turbinePowerMean(ii,i) = mean(turbinePower);
turbinePowerStd(ii,i) = std(turbinePower);
end
end
subplot(1,3,1);
h1 = heatmap(k,Cd,turbinePowerMean/7e6);
title("Mean Power Output for varying k and C_d");
ylabel("Damping coeff kg m^3 s^-^1");
xlabel("Generator control Gain, k");
subplot(1,3,2);
heatmap(k,Cd,turbinePowerStd/7e6);
subplot(1,3,3);
heatmap(k,Cd,turbinePowerMean./turbinePowerStd);