Can't understand how to plot real part of Symbolic Function
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Omer Sholev
 el 28 de Mayo de 2016
  
    
    
    
    
    Respondida: Walter Roberson
      
      
 el 28 de Mayo de 2016
            I'm trying to plot a 3-d graph of the Real part of symbolic function. I have written the code:
syms x real
syms y real
angles = randi([0 360],2,8);
angles = deg2rad(angles);
a = normrnd(0,1,1,8);
a = abs(a);
E = a(1,:).*exp(-1i*K0*(cos(angles(1,:))*x+sin(angles(1,:))*y));
end
And now i want to plot a 3d graph of the real part of the symbolic function E for a range of values of x and y. How can i do that?
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 28 de Mayo de 2016
        [X,Y] = ndgrid(linspace(-5,5), linspace(-3,3));    %your x and y range to plot over
Zr = double(real( subs(E, {x,y}, {X,Y})));         %create numeric real values
Zr = reshape(Zr, size(X,1), size(X,2), []);        %E is a vector so each element generated a surface
nsurf = size(Zr,3);
for K = 1 : nsurf
  ax = subplot(1,nsurf,K);
  surf(ax, X, Y, Zr(:,:,K));
  title( char(E(K)) );
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Calculus en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

