PLOT surface using 3 vectors of same length (NEED HELP!!!)

5 ビュー (過去 30 日間)
Farai Gatawa
Farai Gatawa 2022 年 9 月 13 日
編集済み: Walter Roberson 2022 年 9 月 13 日
please i have managed to make 3 vectors but i want to plot a 3D surface. what am i surposed to do?
b=0;
for i = -200:1:200
for j = -90:0.45:90
b=1+b;
lambda(b) = i;
beta(b) = j;
lambdai =(((lambda(b)+(0.08*beta(b))))*((beta(b)^3)+1))/((beta(b)^3)+1-(0.035*(lambda(b)+(0.08*beta(b)))));
pwrcoff = 0.5109*((116/lambdai)-(0.4*beta(b))-5)*exp(-21/lambdai);
P(b) = 0.5*1.2754*12469*63*55^2*pwrcoff;
end
end

回答 (2 件)

Star Strider
Star Strider 2022 年 9 月 13 日
The code produces vectors, so I would simply reshape them, using the number of unique elements in ‘i’ to determine one of the dimensions —
b=0;
for i = -200:1:200
for j = -90:0.45:90
b=1+b;
lambda(b) = i;
beta(b) = j;
lambdai =(((lambda(b)+(0.08*beta(b))))*((beta(b)^3)+1))/((beta(b)^3)+1-(0.035*(lambda(b)+(0.08*beta(b)))));
pwrcoff = 0.5109*((116/lambdai)-(0.4*beta(b))-5)*exp(-21/lambdai);
P(b) = 0.5*1.2754*12469*63*55^2*pwrcoff;
end
end
% lambda
% beta
% P
RowSize = numel(-200:1:200);
lambdam = reshape(lambda, RowSize,[]);
betam = reshape(beta, RowSize, []);
Pm = reshape(P, RowSize,[]);
Pm = Pm .* ((Pm >= -50) & (Pm <= +5));
figure
surf(lambdam, betam, Pm, 'EdgeColor','none')
grid on
xlabel('\lambda')
ylabel('\beta')
zlabel('P')
.

Bjorn Gustavsson
Bjorn Gustavsson 2022 年 9 月 13 日
You can use multiple indices in the variables you create. For example if you do things like this:
b=0;
for i = -200:1:200
for j = -90:0.45:90
b=1+b;
lambda(i,j) = i;
end
end
You will create 2-D arrays, that you can then use with for example pcolor.
HTH

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by