I have a precipitation values P= [0.5 1 1.5 1] and U=[10 100 200 150 100 50] and I want to create a series like below in matlab.
I write a command like this but I can't run it: Let's say M=4 and N=9
for n=1:9;
syms m;
Q(n)=symsum(P(m)*U(n-m+1),m,1,4);
end
But it gives me the following error.
rror using sym/subsindex (line 732) Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic variables and the body of the function is a SYM expression. When indexing, the input must be numeric, logical, or ':'.
How can I solve this problem ?

 채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 3일
편집: Ameer Hamza 2018년 5월 3일

0 개 추천

You are trying to calculate the convolution of P and U and there is a built-in function in MATLAB for this
Q = conv(P, U);

댓글 수: 2

Gokhan Kayan
Gokhan Kayan 2018년 5월 4일
Thanks Ameer, I tried to write a code but I didn't know that MATLAB has just a short command for this. This is what I exactly want :)
Ameer Hamza
Ameer Hamza 2018년 5월 4일
You are welcome.

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

추가 답변 (0개)

카테고리

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

질문:

2018년 5월 3일

댓글:

2018년 5월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by