How do I implement surfc in app designer?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a problem, in matlab i can code to graph 3D plot of complex function with surfc this is my code for that :
figure
X=-2*pi:0.2:2*pi;
Y=-2*pi:0.2:2*pi;
[x,y]=meshgrid(X,Y);
z=3*x+5i*y;
sc=surfc(x,y,abs(z))
xlabel('Re(x)');
ylabel('Im(y)');
colormap jet
colorbar
but here i want to implement this into app designer. I want user to input the complex function they have in cartesian with x and y (not polar), and then showing that plot to them. But when I run with the same code with a little bit of changes, I always get the error message : "Error using surfc. The surface Z must contain more than one row or column.". Here is my app designer callbacks :
% Button pushed function: MakeGraphButton
function MakeGraphButtonPushed(app, event)
x=-2*pi:0.2:2*pi;
y=-2*pi:0.2:2*pi;
[x,y]=meshgrid(x,y);
z=app.ComplexFunctionEditField.Value;
axes(app.UIAxes);
surfc(x,y,abs(z))
axis equal
grid on
end
end
How to make this works?
0 comentarios
Respuestas (1)
Eric Delgado
el 18 de Nov. de 2022
Try this...
function ButtonPushed(app, event)
x=-2*pi:0.2:2*pi;
y=-2*pi:0.2:2*pi;
[x,y]=meshgrid(x,y);
z = str2func(app.EditField.Value);
surfc(app.UIAxes, x, y, abs(z(x,y)))
axis equal
grid on
end
0 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots 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!