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

6 vues (au cours des 30 derniers jours)
Farai Gatawa
Farai Gatawa le 13 Sep 2022
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

Réponses (2)

Star Strider
Star Strider le 13 Sep 2022
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 le 13 Sep 2022
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

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by