Symbolic summation within a for-loop
Ältere Kommentare anzeigen
I have a function that is dependent on two variables, f(j, k). I would like to create a loop that, for each j, sums the function for each value of k. I have tried the code:
for j=1:10;
g(j)=symsum(f(j,k), k, 1, 10);
end;
However, I get an error message "Undefined function 'symsum' for input arguments of type 'double'." on running the code. What is the best way to do the above in MATLAB?
1 Kommentar
Azzi Abdelmalek
am 22 Jul. 2016
How f is defined?
Akzeptierte Antwort
Weitere Antworten (1)
Azzi Abdelmalek
am 22 Jul. 2016
Look at this example
syms f j k
f=j*sin(k)
for jj=1:10;
ff(k)=subs(f,j,jj);
s=symsum(ff(k), k, 1, 10);
g(jj)=double(s)
end;
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!