Clear Filters
Clear Filters

Resolution of plot code errors

1 view (last 30 days)
영석
영석 on 1 Dec 2023
Commented: Voss on 1 Dec 2023
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

Accepted Answer

Les Beckham
Les Beckham on 1 Dec 2023
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

More Answers (1)

Voss
Voss on 1 Dec 2023
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 Comments
영석
영석 on 1 Dec 2023
That's what I wanted. thank you:)
Voss
Voss on 1 Dec 2023
You're welcome! If this answer helped, please vote for and/or Accept it. Thanks!

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!