필터 지우기
필터 지우기

what does the x(10:15) mean?

조회 수: 4 (최근 30일)
Kevin Brinneman
Kevin Brinneman 2018년 10월 31일
댓글: Star Strider 2018년 10월 31일
Hello everyone,
I am reading a code developed by someone else and don't understand what does the x(10:15).'*x(4:9).
I know that you can solve a set of variables by using a function and going like this: x(1) x(2) etc.
Here's the section of the code: y_hat = x(10:15).'*x(4:9);
How do you call that notation? x(10:15) so I can look it up and read about it in forums.
Thanks!

채택된 답변

Star Strider
Star Strider 2018년 10월 31일
편집: Star Strider 2018년 10월 31일
This assignment:
y_hat = x(10:15).'*x(4:9);
if ‘x’ is a row vector, does matrix multiplication of the transposed 5 elements of ‘x’ from ‘x(10)’ to and including ‘x(15)’ (to create a column vector) by the elements of ‘x(4:9)’ to create a matrix. If ‘x’ is a column vector, this calculated the dot product instead.
See the documentation on Array vs. Matrix Operations (link) for a relevant discussion.
  댓글 수: 2
Torsten
Torsten 2018년 10월 31일
I think - depending on whether x is a row or column vector - y_hat is a 6x6 matrix or a scalar.
Star Strider
Star Strider 2018년 10월 31일
@Torsten — Oops! I did not see the transpose!
I revised my Answer accordingly.
Thanks!

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

추가 답변 (1개)

madhan ravi
madhan ravi 2018년 10월 31일
편집: madhan ravi 2018년 10월 31일
x(10:15)
it means elements from 10 to 15 are picked from vector x
see example:
>> x=1:15
x =
Columns 1 through 13
1 2 3 4 5 6 7 8 9 10 11 12 13
Columns 14 through 15
14 15
>> x(11:15)
ans =
11 12 13 14 15
>>
  댓글 수: 1
madhan ravi
madhan ravi 2018년 10월 31일
편집: madhan ravi 2018년 10월 31일
How do you call that notation?
its called as vector indexing

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by