Problem with writing this function
이전 댓글 표시
I do not understand what is wrong with this function. When I try to run the function written like this the error down below comes up.
y = (x.-1)/((x.^2).+x)

채택된 답변
추가 답변 (1개)
Vikas Kumar
2019년 10월 9일
0 개 추천
Agree with Jon. I think you are getting error because of . operator you use with the addition and subtraction. This . operator is only meaningful when you want to do element by element operation, which in case of addition and subtraction is by default.
So:
y = (x-1)./((x.^2)+x)
댓글 수: 1
Jon
2019년 10월 9일
Note also that parenthesis around exponentiation are not necessary either. They do not cause an error, but make the expression harder to read.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!