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!