0
votes

I was following the following example for matlab: http://se.mathworks.com/help/matlab/creating_plots/contour-plot-in-polar-coordinates.html. This example works, but when I want to plot my own data, the figure does not change, and I get no output. Plotting my data as usual with contour() works. What am I doing wrong?

Edit: The code from the example is:

th = (0:5:360)*pi/180;
r = 0:.05:1;
[TH,R] = meshgrid(th,r);
[X,Y] = pol2cart(TH,R);
Z = X + 1i*Y;
f = (Z.^4-1).^(1/4);

figure
surf(X,Y,abs(f))
colormap summer;
hold on
surf(X,Y,zeros(size(X)))
hold off
xlabel('Real')
ylabel('Imaginary')
zlabel('abs(f)');
figure
contour(X,Y,abs(f),30)
axis equal
xlabel('Real')
ylabel('Imaginary')
h = polar([0 2*pi], [0 1]);
delete(h)
hold on
contour(X,Y,abs(f),30)

My values are a, b and c, representing a meshgrid (as TH and R do) and c which is a height matrix. I simply replaced the last command:

contour(a, b, c, 30)

a is a 361x361-sized matrix with range from 2 to 226, b the same. c goes from 0.5 to 50 and is 361x361-sized.

1
we dont know. You didnt show us code. - Ander Biguri
@AnderBiguri: Code added, I hope that is everything you need. - arc_lupus
It would be better if you only showed us your code. - knedlsepp
We can see the code of the example that works, what about you show us the code that doesnt work? - Ander Biguri
@AnderBiguri: The last line does not work, i.e. if I enter it, nothing in the figure changes. If you want to get the values of a, b and c, that is a long calculation, including several data from external files. But the command itself without mapping it onto a polar field works. - arc_lupus

1 Answers

0
votes

Ok, the solution of the problem was simply to rewrite this line

h = polar([0 2*pi], [0 1]);

to

h = polar([0 2*pi], [0 max(a)]);

because my data started at a x-value of 2, and was therefore not displayed in the range from 0 to 1.