interpolation to maximum points

1 次查看(过去 30 天)
Hi all, I have below code to generate a group of graphs. I need to interpolate a line through their maximum points. could you please help? in addition I need to cut the graph below the -0.1 if it is possible. Thanks
Cp=[ ];
landa=(0:0.1:16);
for B=0:3:30
for i=1:1:length(landa)
landa_i=1/((1/(landa(i)+0.08*B))-(0.035/(B^3+1)));
Cpi=0.22*((116/landa_i)-(0.4*B)-5)*exp(-12.5/landa_i);
Cp=[Cp Cpi];
end
if B==0
Cpmax=max(Cp);
end
plot(landa,Cp,'b');
% mesh(landa,B);
hold on;
Cp=[ ];
end
xlabel('Tip speed ratio');
ylabel ('Performance corfficient Cp');
hold off;

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2012-8-24
close
Cp=[ ];
landa=(0:0.1:16);
result=[];
for B=0:3:30
for i=1:1:length(landa)
landa_i=1/((1/(landa(i)+0.08*B))-(0.035/(B^3+1)));
Cpi=0.22*((116/landa_i)-(0.4*B)-5)*exp(-12.5/landa_i);
Cp=[Cp Cpi];
end
if B==0
Cpmax=max(Cp);
end
result=[result Cp'];
plot(landa,Cp,'b');
% mesh(landa,B);
hold on;
Cp=[ ];
end
xlabel('Tip speed ratio');
ylabel ('Performance corfficient Cp');
%hold off;
[i1,j1]=max(result)
xi=landa(j1);yi=i1;
xyi=sortrows([xi' yi'],1)
hold on
x1=landa(min(j1):max(j1))
y1=interp1(xyi(:,1),xyi(:,2),x1);
plot(x1,y1,'r')
set(gca,'ylim',[-0.1 max(i1)])
  2 个评论
Alzapoa
Alzapoa 2012-8-24
Hi Azzi, Thanks for the solution. if you look at the result plot the red line goes to landa=0.4382 and then back down which is not meant to do that. it should go through the max values independent from the order of plot. so what to do with that I hope I am clear.
Azzi Abdelmalek
Azzi Abdelmalek 2012-8-24
but i ve used your result. what kind of interpolation do you want?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by