Please someone could help me how to do this in a loop; I am kind of begginer in Matlab:

댓글 수: 3

Walter Roberson
Walter Roberson 2016년 9월 13일
Is U superscript arrow subscript j a function or a vector?
Chad Greene
Chad Greene 2016년 9월 13일
What have you tried so far?
Miguel L
Miguel L 2016년 9월 13일
U is avector

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

 채택된 답변

John BG
John BG 2016년 9월 13일

0 개 추천

Hi Miguel
with no further information the following does what you ask for
U=randi([-10 10],1,10)
=
7.00 9.00 -8.00 9.00 3.00 -8.00 -5.00 1.00 10.00 10.00
Select a p such is smaller that at least length(U)-1, for instance
p=3
the limit for the sum is
L=length(U)-p
L =
7.00
and now let's calculate S
S=zeros(1,L);
for k=1:1:L
S(k)=sum(U([1:k+p]));
end
17.00 20.00 12.00 7.00 8.00 18.00 28.00
Since T does not show the vector arrow I understand it's a scalar, so to complete just multiply
S=T*S
If T is a vector, then you could either multiply element by element with
S=T.*S
provided T and S have same size
Miguel
if you find this answer useful would you please be so kind to mark my answer as Accepted Answer?
if you consider there is need for further clarification before you mark my answer as accepted do not hesitate to let me know what else would be required.
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2016년 9월 13일

댓글:

2016년 9월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by