필터 지우기
필터 지우기

symsum undefined error for input arguments

조회 수: 1 (최근 30일)
Margherita Premoli
Margherita Premoli 2020년 3월 5일
답변: Steven Lord 2020년 3월 5일
Hi, I need to sum the variable Dmet(b,t) over b, which varies from 1 to b-1.
The variable Dmet is the demand met at a certain day t with a certain batch b so Dmet is defined by two indices.
I tried to formulate it but it is not working, can anyone help me out? Thanks!!
This is part of the code:
syms b
D= 10
for t=1
for b=1:3
Dmet(1,t)=3
Dmet(2,t)=4
Dmet(3,t)= D - symsum(Dmet(b,t),b,1,b-1)
end
end
Do I have to use a syms diffferent than b?

채택된 답변

Steven Lord
Steven Lord 2020년 3월 5일
Your b variable isn't symbolic at the time you try to use it in symsum. It was overwritten by the loop variable for your inner loop.
But even if it wasn't, symsum isn't the right tool for this job. Use sum instead.
A = reshape(1:16, 4, 4)
sum(A(:, 1:3), 2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by