please help
이전 댓글 표시
i am using the code from a former student. i run it and i gave me this error:
??? Undefined function or method 'Political' for input arguments of
type 'char'.
what does it mean? how can i change it right? the code is given as below from the former student.
X = xlsread('Political 2008.xlsx','sheet1','A1:G83');
Y = xlsread('Political 2008.xlsx','sheet1','H1:H83');
s = length (Y(1,:));
m = length (X(1,:));
for j = 1:83
f = [-Y(j,:) zeros(1,m)]';
Aeq = [zeros(1,s) X(j,:)];
beq = 1;
A = [Y -X];
b = zeros(83,1);
lb = zeros(m+s,1);
uv(:,j) = LINPROG(f,A,b,Aeq,beq,lb);
h(j) = -f'*uv(:,j);
end
please help. thank you
답변 (2개)
Fangjun Jiang
2011년 12월 20일
0 개 추천
It's a little strange because you are not using "Political" as a variable or function.
My guess is that: 1) Your Excel version is different than the origianl intended. 2) The file "Political 2008.xlsx" is not in your current folder. 3) Your MATLAB version might have problem with the Excel file name with a white space in it.
Try to copy the "Political 2008.xlsx" file to your current folder, re-name it so it doesn't contain white space in the name, change the Excel file name in the above code and run it again.
댓글 수: 6
Titus Edelhofer
2011년 12월 20일
Additionally: take a look at what "which xlsread" gives. Is it something like <matlab>\toolbox or some function of yours or a variable?
Titus Edelhofer
2011년 12월 20일
And by the way: you will need to write linprog instead of LINPROG.
kelvin lee
2011년 12월 20일
Titus Edelhofer
2011년 12월 20일
Hi Kelvin, one last question: in which line of the code does the error occur, in the line with "xlsread"?
Malcolm Lidierth
2011년 12월 20일
@Titus
My guess is not.
>> Political 2008.xlsx
Undefined function 'Political' for input arguments of type 'char'.
kelvin lee
2011년 12월 22일
kelvin lee
2011년 12월 22일
0 개 추천
댓글 수: 1
Fangjun Jiang
2011년 12월 22일
Interesting! I guess everyone has a lesson learned here.
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!