Creating both series and for loop
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gokhan Kayan
am 3 Mai 2018
Kommentiert: Ameer Hamza
am 4 Mai 2018
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/190277/image.png)
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 ?
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 3 Mai 2018
Bearbeitet: Ameer Hamza
am 3 Mai 2018
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!