If I have a function given as x =f(y), how can I plot x as independent variable (x axsis) and y dependent variable (y axsis). I also need to control the range of both x and y.
x=y/(0.5+cos3y)

댓글 수: 1

Walter Roberson
Walter Roberson 2020년 3월 5일
Could you confirm that you need to do this inside a mex routine? Or are you trying to use MATLAB Coder? I am trying to figure out what the Product tag you used implies for this.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 5일

0 개 추천

In MATLAB, cos3y would be written as cos(3*y)
In MATLAB, if y is a vector, instead of using / you should use ./ -- so y./something instead of y/something
You have an implicit plot, so you should have a look at fimplicit()

댓글 수: 7

Mariam
Mariam 2020년 3월 5일
Let me rephrase my question, I am trying to make a code by matlab for plotting the following equation:
y= (0.5+cos(3*y))*x for both x and y to have the values: form 0 to 1e4. I have never come across with such an equation and I need to know how to solve it numerically.
All the best
Walter Roberson
Walter Roberson 2020년 3월 5일
편집: Walter Roberson 2020년 3월 5일
In MATLAB, most of the time you need to express multiplication using the .* operator instead of the * operator.
You have an implicit plot, so you should have a look at fimplicit()
Hint:
If A(x,y) = B(x,y) then A(x,y)-B(x,y) = 0 must be true, and expression being 0 is what fimplicit() draws.
Mariam
Mariam 2020년 3월 5일
I have tried the following:
f=@(x,y) y-(0.5+cos(3.*y)).*x;
fimplicit(f, [0 1e4 0 1e4])
an error message tells me that "undefined function or method 'fimplicit' for input arguments of type 'fuction handle'".
Walter Roberson
Walter Roberson 2020년 3월 5일
Which MATLAB release are you using? fimplicit() was added in R2016b.
Mariam
Mariam 2020년 3월 5일
it is R2009a.
Walter Roberson
Walter Roberson 2020년 3월 5일
In R2009a, you can use
ezplot(f, [0 1e4 0 1e4])
Mariam
Mariam 2020년 3월 6일
Many thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

질문:

2020년 3월 5일

댓글:

2020년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by