フィルターのクリア

A simple scatter plot from a 2d matrix

171 ビュー (過去 30 日間)
Emmanouil Karamousadakis
Emmanouil Karamousadakis 2021 年 10 月 19 日
編集済み: Emmanouil Karamousadakis 2021 年 10 月 20 日
Hello, I couldnd find the answer anywhere :(
I am looking to make a simple scatter plot, with 1:5 range on both axes, that show a marker at the a1,a2 locations
Ideally, it wouldnt hurt to show the calculated f(a1,a2) value of each point, or maybe colorcode the markers but thats not crucial.
I tried quite a few: plot, plot3, surf, scatter, without success :(
Here is my code:
a1=rand(5,1)*3;
a2=rand(5,1)*3;
[x1, x2] = meshgrid(a1,a2);
ff= -sin(x1).*(sin(x1.^2./pi())).^2 -sin(x2).*(sin(2.*x2.^2./pi())).^2;
Thank you!!

採用された回答

Kelly Kearney
Kelly Kearney 2021 年 10 月 20 日
Are any of these what you're looking for?
a1=rand(5,1)*3;
a2=rand(5,1)*3;
[x1, x2] = meshgrid(sort(a1),sort(a2)); % sort for for surf plot
ff= -sin(x1).*(sin(x1.^2./pi())).^2 -sin(x2).*(sin(2.*x2.^2./pi())).^2;
subplot(2,2,1);
plot(x1, x2, 'k.');
title('plot');
subplot(2,2,2);
plot3(x1, x2, ff, 'k.');
title('plot3');
subplot(2,2,3);
surf(x1,x2,ff);
title('surf');
subplot(2,2,4);
scatter(x1(:), x2(:), [], ff(:), 'filled');
title('scatter');
  1 件のコメント
Emmanouil Karamousadakis
Emmanouil Karamousadakis 2021 年 10 月 20 日
編集済み: Emmanouil Karamousadakis 2021 年 10 月 20 日
Amazing! I was overthinking #1 subplot, that works fine.
But the #4 is GREAT!!!
Thank you!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by