![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1197838/image.png)
How do I implement surfc in app designer?
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Eric Delgado
2022 年 11 月 18 日
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1197838/image.png)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!