how to make a column vector with evenly spaced entries with different coefficients
이전 댓글 표시
I am trying to make the following 16x1 column vector
y = 3 %given, could be any value
ycoeff = [0;0;0;-4y;0;0;0;-3y;0;0;0;-2y;0;0;0-y]
If you could help me i would be very appreciative.
Thank you!
댓글 수: 2
madhan ravi
2019년 3월 15일
doc colon
Jos (10584)
2019년 3월 15일
You forgot to add the multiplication symbol, and a semi-colon is missing before the last y ...
y = 3 %given, could be any value
ycoeff = [0;0;0;-4*y;0;0;0;-3*y;0;0;0;-2*y;0;0;0 ; -y]
Yet, somehow I feel that this is not the real question you want to have asnwers to ... :-D
채택된 답변
추가 답변 (1개)
Jos (10584)
2019년 3월 15일
A simple one-liner:
y = 3 ;
k = 4 ;
ycoeff(k:k:(k*k), 1) = (-k:-1)*y
댓글 수: 2
madhan ravi
2019년 3월 15일
Impacts Andrei's second solution on a larger scale ;-)
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!