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

조회 수: 6 (최근 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 CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by