Problem in using coeffs in a file

I am using Matlab mobile (Android), version 4.2.0.
I am creating a function, in which I am using the coeffs function. I want to extract the coefficients of x and y from an expression and use them elsewhere.
Say, my expression is x - y. If I use coeffs function in the command line, I get back an array, which is what I want. The code has been attached in the screenshot.
The command line gives me just what I want. But when I try do do the same from a file, an error comes up. See the other screenshot attached. In the second screenshot, plot2d is the function I have written, and eqn2 is the expression in which I want to find the coefficients of x and y. The line in the function is simply:
coeffs(eqn2,x)
I must add here that if I put the coeffs function in a different file and call that file, it works fine.
Any help is appreciated.

댓글 수: 5

Walter Roberson
Walter Roberson 2018년 8월 1일
Please show your code for plot2d
Wrichik Basu
Wrichik Basu 2018년 8월 1일
Thank you, but I've found my mistake.
Kevin Chng
Kevin Chng 2018년 8월 2일
What is the errors you found? Have a nice day.
Wrichik Basu
Wrichik Basu 2018년 8월 2일
When I was using coeffs(eqn2,x), there was some value stored in x already, which was causing the problems.
Kevin Chng
Kevin Chng 2018년 8월 3일
Okay. great.....thanks for your sharing

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

답변 (1개)

Kevin Chng
Kevin Chng 2018년 8월 1일

0 개 추천

Hi Wrichik Basu,
Do you mind to share your equation 2 here? Your error could be similar to case as below:

댓글 수: 1

Wrichik Basu
Wrichik Basu 2018년 8월 1일
eqn2 depends on on the values of X and Y. But it is always a linear expression in x and y. You can take anything as eqn2. It has the form Ax + By + C, where A, B and C are constants.

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

카테고리

도움말 센터File Exchange에서 Setup and Configuration에 대해 자세히 알아보기

제품

릴리스

R2018a

태그

질문:

2018년 7월 31일

다시 열림:

2018년 12월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by