surface plot

2 ビュー (過去 30 日間)
Bahareh
Bahareh 2011 年 11 月 29 日
コメント済み: Albert J. G. 2019 年 4 月 6 日
Hello all,
I have the following code:
a = 0:.1:1;
b = 0:.01:.1;
for k = 1:length(a)
c = a(k) + b(k);
end
I would like to plot 'c' versus 'a' and 'b' using 'surfl'; Is there a way to do it? thanks.

回答 (3 件)

Grzegorz Knor
Grzegorz Knor 2011 年 11 月 29 日
[a b] = meshgrid(0:.1:1,0:.01:.1);
c = a + b;
surfl(a,b,c)
  1 件のコメント
Walter Roberson
Walter Roberson 2011 年 11 月 29 日
Bahareh's previous question was specifically asking about combining a(K) and b(K) instead of producing a grid, so it seems your code (fine in most circumstances) is not what is desired _here_

サインインしてコメントする。


Walter Roberson
Walter Roberson 2011 年 11 月 29 日
a = 0:.1:1;
b = 0:.01:.1;
c = a + b;
t = nan(length(a),length(a));
z = diag(c) + tril(t,-1) + triu(t,1); %defined on diag, else nan
surfl(a,b,z);
I would not expect the plot to have any useful content, though. surface plots do interpolation from vertices to determine what to draw, but you are only defining the result along a line.
I will not suggest that you want the entire grid of a(J) + b(K) values as that would not be in accordance with your previous question.

Albert J. G.
Albert J. G. 2019 年 3 月 17 日
This question is about how to plot a surface diagram.
The data are in an excel file, as you can find.
My question is how to plot a surface diagram using data from A2 to C72? (if you think data is no enough, you can use C491)
Maybe x=kp; y = ki; z = delay. What I need is like surf(x,y,z), and it will give a surface plot with NO ERROR (this is the most important, I think).
This is the question borthering me for a long time.
BTW, it not hard to plot a 3D scattor diagram, using:
[num, txt]= xlsread('rank.xlsx', 'A2:C72');
x = num(:,1);
y = num(:,2);
z = num(:,3);
% the point on 3d diagram:
plot3(x,y,z,'.','color','black','markersize',12)
xlabel('kp')
ylabel('ki')
zlabel('delay')
grid on
But I really donnot how to plot a surface since Z do not have a obvious relation with X and Y.
  11 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 6 日
Perhaps you would prefer a different approach:
num = xlsread('rank.xlsx', 'A2:C10745');
x = num(:,1);
y = num(:,2);
z = num(:,3);
K = boundary(x, y, z, 1);
trisurf(K, x, y, z);
Albert J. G.
Albert J. G. 2019 年 4 月 6 日
Wow! That works!! Thx!!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by