I have tried to plot this function:
t=linspace(0,2*pi,100);
a=input('a= ');
b=input('b= ');
c=input('c= ');
k = a*(1-(sin(3*t)).^(2*b))+c;
polar(t,k)
% a=2.6
% b=0.4
% c=5
Each time, I get the following message:
Warning: Imaginary parts of complex X and/or Y arguments ignored.
I have tried the pol2cart method as such:
t=linspace(0,2*pi,100);
a=input('a= ');
b=input('b= ');
c=input('c= ');
k = a*(1-(sin(3*t)).^(2*b))+c;
[x,y] = pol2cart(t,k);
plot(x,y)
I got the same message again.
I have tried to convert it to spherical coordinates, it didn’t work. I have also tried the arrayfun method as suggested in a forum answer, it didn’t work as well.
Can someone please help me?
Thank you!
Your problem is in your function.
kcontains imaginary numbers, because of this:If you want to make sure it doesn’t contain imaginary numbers, you need to increase
b. Bottom line is, fix your formula. I can only suppose you mean something like this, but there could be other solutions. Essentially, I think you mean to take the exponent of 1-sin, not sin.This gives the following plot (From Octave, but it should be the same)
I figured this out by `plot(k). If k contains imaginary, it will plot the real vs imaginary components. If it is purely real, it will plot the line vs time.