0

The thing is i have a matrix and when i use imagesc() it goes like this but my goal is this. So my question is does any one know which plot is this or some one has document about this, thanks.

2
  • Judging from the two images, maybe your data is in polar coordinates (imagesc uses Cartesian coordinates). Also, the goal image seems to use the jet colormap Commented May 29, 2020 at 17:02
  • Yes, i spent last 5 days trying to wrote in polar coordinate but it fail. And now i'm in stress with polar plot. Commented May 30, 2020 at 6:52

1 Answer 1

1

If you have two vectors r and theta that give the polar coordinates, or two matrices rGrid and thetaGrid that give the polar coordinates for each element of the data matrix, then code like this will work:

r=linspace(1,20,20);
theta=linspace(0,2*pi,20);

data = r'.*sin(2.*theta); % INSERT DATA HERE

[thetaGrid,rGrid]=meshgrid(theta,r); % Create coordinate grid if needed
[xGrid,yGrid]=pol2cart(thetaGrid,rGrid);

surf(xGrid,yGrid,data); % Plot data
view(2);

Polar plot

Just keep in mind that the rows of the data matrix need to correspond to different radii, and columns need to correspond to different values of theta. If it's flipped, then transpose the matrix before plotting:

data = data';

Also, if the data doesn't wrap around from 0 to 2*pi radians, then repeat the first value of theta as the last value, and repeat the first column of the data matrix as a new final column:

theta(end+1)=theta(1);
data=cat(2,data,data(:,1));

There is also a 3D Polar Plot function on the MATLAB file exchange, but I do not have any experience using it: 3D Polar Plot

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.