How do I select specific points from the meshgrid function?

I have created a meshgrid and would like to select specific coordinates (rho, theta) on it in order to see their value relating to my Gauss-Laguerre beam I am inspecting.
rseed=[0*max(w):max(w)/30:3*max(w)];
thetaseed=[0:360]*pi/180;
[r,theta]=meshgrid(rseed,thetaseed)

 採用された回答

Walter Roberson
Walter Roberson 2017 年 11 月 9 日

1 投票

The value at probe_r, probe_theta is approximately
interp2(r, theta, GaussLaguerreValues, probe_r, probe_theta)

3 件のコメント

Robbie McCormack
Robbie McCormack 2017 年 11 月 9 日
Thanks for the quick response, having a few errors when I use what you gave me, could you maybe shed some light where I'm going wrong? (apologies, still getting used to MATLAB).
Error using griddedInterpolant
Interpolation requires at least two sample points in
each dimension.
Error in interp2>makegriddedinterp (line 230)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 130)
F = makegriddedinterp({X, Y}, V,
method,extrap);
Error in MYTEST3 (line 17)
V=interp2(r,theta,E,probe_r,probe_theta);
Walter Roberson
Walter Roberson 2017 年 11 月 10 日
This disagrees with the r, theta meshgrid that you show you were creating. r and theta for this purpose should be those meshgrid results, and E should be the function evaluated at those locations. Then probe_r and probe_theta should be the places you want to ask about the value of.
Robbie McCormack
Robbie McCormack 2017 年 11 月 10 日
My mistake, I altered the meshgrid by accident while trying to get the code to work, that's why I was getting errors.
You've been a massive help, thank you. If there's any way of up-voting your profile or answer other than making it the accepted one please let me know.

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by