MATLAB Fixing Error in MATLAB 10a for 3D Plotting

  • Thread starter Thread starter adnan jahan
  • Start date Start date
  • Tags Tags
    Error Matlab
AI Thread Summary
The user encountered a syntax error in MATLAB 10a while trying to plot a 3D mesh with complex numbers, which worked in MATLAB 7. The error message indicated that the mesh function cannot handle complex inputs. A solution was provided to use the real part of the complex variable by applying the 'real' function before plotting. This adjustment resolved the issue, allowing the user to successfully generate the 3D plot without reverting to the older version of MATLAB. The discussion highlights the differences in handling complex numbers between MATLAB versions.
adnan jahan
Messages
93
Reaction score
0
Dear Fellows,
I have a program made in MATLAB-7 , about 3D plotting,
simplest form of program is
[x,z]=meshgrid(linspace(0,4),linspace(-1,1));
t=0.1;
b=1.2;
w=-1.0;
k=2+3*i;
M=4+5*i;
u1=k*M;
u=u1.*exp(w*t+i*b*z);

mesh(u)

this works properly in matlab-7
but when I open it in matlab-10a it gives following syntax error
? Error using ==> mesh at 80
X, Y, Z, and C cannot be complex.

Error in ==> abc at 9
mesh(u)

can anyone help me out to get solve this issue?? I don't want to switch back to same old version of matlab,

thanks
 
Physics news on Phys.org
take only the real part:

mesh(real(u))

And compare it to your MATLAB 7 result. It's likely that 7 just automatically takes the real part and doesn't tell you.
 
yessss! thanks Pythagorean for your reply,,

It really works...
 

Similar threads

Replies
1
Views
2K
Replies
6
Views
4K
Replies
2
Views
3K
Replies
1
Views
2K
Replies
4
Views
3K
Replies
1
Views
2K
Back
Top