How to plot peaks on desired location in a 3D plot?

2 ビュー (過去 30 日間)
Sadiq Akbar
Sadiq Akbar 2022 年 2 月 21 日
コメント済み: Star Strider 2022 年 3 月 2 日
There are two vectors that will make an xy-plane. I want to draw a peak pointing in z-direction on a desired location on the xy-plane. In code form it is:
x=linspace(0,180,100);% 1st vector
y=x;% 2nd vector
Now I want to draw a peak of strenght 5 on the intersection of the point (x1,y1)=(30,50).Likewise, I want to draw another peak on the intersection of the point (x2,y2)=(40,120). Further, I want to draw another peak on the intersection of the point (x3,y3)=(60,140). But this whole plot should be a 3D plot as shown in the attached image.
  2 件のコメント
Matt J
Matt J 2022 年 2 月 21 日
What determines the z-valeus everywhere where there isn't a peak?
Sadiq Akbar
Sadiq Akbar 2022 年 2 月 21 日
Thank you for your response. There is no eq. but I want to draw peaks of my desired values. Say for example, one peak should be of height 5, another should be of height 5.5 and another should be of height 7.

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

採用された回答

Star Strider
Star Strider 2022 年 2 月 21 日
[X,Y] = ndgrid(0:300);
C = 50:100:300;
Zf = @(C) exp(-(((X-C).^2)*0.5+((Y-C).^2)));
Z = Zf(C(1)) + Zf(C(2)) + Zf(C(3));
[pks,locs] = findpeaks(Z(:), 'MinPeakHeight',0.5)
pks = 3×1
1 1 1
locs = 3×1
15101 45301 75501
figure
surf(X, Y, Z, 'EdgeColor','none')
hold on
plot3(X(locs), Y(locs), Z(locs), '^r')
hold off
Experiment with your data with this approach.
.
  8 件のコメント
Sadiq Akbar
Sadiq Akbar 2022 年 3 月 2 日
Thank you very much dear Star Strider for your help.
Star Strider
Star Strider 2022 年 3 月 2 日
As always, my pleasure!

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

その他の回答 (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