필터 지우기
필터 지우기

Did not get the row vector as expected.

조회 수: 2 (최근 30일)
Zuhri Ashraaf
Zuhri Ashraaf 2020년 12월 6일
댓글: Zuhri Ashraaf 2020년 12월 6일
Hi everyone!
I have this code.
x = 0:0.1:100;
y = cos(x)/(2-cos(x));
I was expecting my y to be a row vector too like x. However, when I declare it, the output is only y = -0.1122.
The question is why is that and what should I do to make y as a vector like x.
I haven't finish my Onramp tutorial, but I'm just curious and at the same time confused.
Sorry if my question is too basic to be asked and sorry again for my bad English.
Thank you in advanced!

채택된 답변

Image Analyst
Image Analyst 2020년 12월 6일
편집: Image Analyst 2020년 12월 6일
You're doing a "matrix division". Try dot slash to do an element-by-element division:
x = 0:0.1:100;
y = cos(x) ./ (2-cos(x));
  댓글 수: 1
Zuhri Ashraaf
Zuhri Ashraaf 2020년 12월 6일
That makes a lot of sense and it works!
Thank you so much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by