using symsum for elements of array

1 view (last 30 days)
Hello everyone I wrote this code:
syms q
llayers=5;
effstress=zeros(1,llayers);
thick=[20 30 10 20 50]
rho=[120 130 120 150 140]
for i=2:llayers
effstress(1,i)=symsum(thick(q).*rho(q),1,i-1)
end
Would you please help me in this issue? Thanks a lot

Accepted Answer

Star Strider
Star Strider on 28 Nov 2015
I am not certain I understand what you want.
See if this works:
thick=[20 30 10 20 50];
rho=[120 130 120 150 140];
effstress = cumsum(thick .* rho);
effstress =
2400 6300 7500 10500 17500

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!