Help needed on error!!!!!
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 13 de Feb. de 2012
Ouch! Ouch!
if inputarg(j).(fieldname) < inputarg(low).(fieldname)
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!