Help needed on error!!!!!
1 回表示 (過去 30 日間)
古いコメントを表示
Hi guys,
I've got this error expression.. can someone help vet through my script and see what's wrong? thanks.
Script:
function outv = generalPackSort (inputarg, fieldname)
if isfield(inputarg, fieldname)
for i =1:length(inputarg) -1
low = i;
for j= i + 1:length(inputarg)
if eval (['inputarg ('int2str(j)').'fieldname])< ...
eval (['inputarg ('int2str(low)').'fieldname])
low = j;
end
end
%Exchange elements
temp = inputarg(i);
inputarg(i)=inputarg(low);
inputarg(low) = temp;
end
outv = inputarg;
else
outv = [];
end
end
Command window:
>> packByPrice = generalPackSort (packages, 'price')
??? Error: File: generalPackSort.m Line: 6 Column: 38
Unexpected MATLAB expression.
The error is in "if eval (['inputarg ('int2str(j)').'fieldname])< ...". But I can't figure out what's wrong.
0 件のコメント
回答 (1 件)
Walter Roberson
2012 年 2 月 13 日
Ouch! Ouch!
if inputarg(j).(fieldname) < inputarg(low).(fieldname)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!