Resolution of plot code errors

1 次查看(过去 30 天)
syms x;
y=1/sqrt((1-x^2)^2+(2*x)^2);
plot(x,y);
xlim([0 5]); ylim([0 4]);
I can't draw a graph. A code error appears
I need your help

采纳的回答

Les Beckham
Les Beckham 2023-12-1
Why are you trying to do this with symbolic variables? It works using simple numeric variables.
x = linspace(-5, 5, 500);
y = 1 ./ sqrt((1-x.^2).^2 + (2*x).^2); % <<< use element-wise powers and division
plot(x, y);
% xlim([0 5])
ylim([0 4])
grid on

更多回答(1 个)

Voss
Voss 2023-12-1
Use fplot instead of plot:
syms x;
y=1/sqrt((1-x^2)^2+(2*x)^2);
fplot(x,y);
xlim([0 5]); ylim([0 4]);
  2 个评论
영석
영석 2023-12-1
That's what I wanted. thank you:)
Voss
Voss 2023-12-1
You're welcome! If this answer helped, please vote for and/or Accept it. Thanks!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by