フィルターのクリア

How to plot a 3D plot from three linear vectors?

15 ビュー (過去 30 日間)
Sadiq Akbar
Sadiq Akbar 2022 年 2 月 21 日
コメント済み: Matt J 2022 年 2 月 21 日
I have three vectors x ,y and z. The size of all of them are same.But all of them are 1D arrays. I want to draw a 3D plot from them. Let me give it in code form as below:
x=linspace(0,180,100);% 1st vector
y=x;% 2nd vector
z=rand(1,100)*1e-7;% 3rd vector
I tried to convert both x and y to 2D vectors as below:
[x,y]=meshgrid(x,y);
But when I use the surface command or mesh command, it gives me error as:
Z must be a matrix, not a scalar or vector.
What to do?

採用された回答

Matt J
Matt J 2022 年 2 月 21 日
編集済み: Matt J 2022 年 2 月 21 日
x=linspace(0,180,100);% 1st vector
y=x;% 2nd vector
z=rand(1,100)*1e-7;% 3rd vector
line(x,y,z); view(3)
  2 件のコメント
Sadiq Akbar
Sadiq Akbar 2022 年 2 月 21 日
Thank you very much dear Matt J. The 2nd problem is a little bit different from above. This time both x and y vectors are of same length but I want to plot peaks on intersection of the points of x and y axes i.e., I want to draw one peak on each i.e.,
(x1,y1)=(50,50)
(x2,y2)=(70,120)
(x3,y3)=(30,65)
Matt J
Matt J 2022 年 2 月 21 日
The 2nd problem is a little bit different from above.
If your first problem has been solved, please Accept-click the answer. If you have a new problem, please post it in a separate thread.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by