Undefined function or variable
이전 댓글 표시
Hello everyone,
I have written following code to calculate the production costs. The price_matrix is a 360x13 double matrix and the variable a is a binary variable.
The price_matrix is stored in the base workspace. The error "Undefined function or variable 'price_matrix'." occurs. How do I import the matrix in my function.
function [total_costs] = costs_calculation (a)
t=1;
while t<=360
ct=price_matrix(t,2)*a(1,1) +price_matrix(t,3)*a(1,2) + price_matrix(t,4)*a(1,3)+price_matrix(t,5)*a(1,4) +price_matrix(t,6)*a(1,5) + price_matrix(t,7)*a(1,6) +price_matrix(t,8)*a(1,7) +price_matrix(t,9)*a(1,8) + price_matrix(t,10)*a(1,9) +price_matrix(t,11)*a(1,10) +price_matrix(t,12)*a(1,11) + price_matrix(t,13)*a(1,12);
total_costs=total_costs + ct;
end
end
Thanks a lot in advance.
댓글 수: 3
Geoff Hayes
2019년 1월 2일
Alexander - where are you calling the costs_calculation function from? If calling it from the base workspace (command line) then just pass in the price_matrix as an input parameter to this function. If you are not calling this function from the base workspace, then how/where is it being called from (and why is the matrix defined in the base workspace...)?
Alexander Bork
2019년 1월 2일
편집: Image Analyst
2019년 1월 2일
Image Analyst
2019년 1월 2일
Alexander, not sure you saw my Answer down in the official "Answers" section below. Did you?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Scripts에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!