简体   繁体   中英

MATLAB - Only plot a spherical section of data set which is cubic

I have a physics model that simulates a few things in a radius of 5000 km around an object in spherical coordinates. I found no way to interpolate spherical coordinates in MATLAB so I changed them to Cartesian with sph2cart function. Then I used scatteredinterpolant function with a 10000 by 10000 by 10000 km meshgrid to interpolate the data. I want to plot this data but only the sphere of a radius 5000 km. Is there a nice way to plot a certain specified volume of the data?

If you just want to delete part of your data "spherically" you can do

being x,y,z your geometric data and v the values:

level=5000; %km (or whatever value it is in your data)
V(sqrt(X.^2+Y.^+Z.^2)>level)=0;

%or depending in the plotting functions.

V(sqrt(X.^2+Y.^+Z.^2)>level)=NaN; 

% plot things

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM