fprintf error:function not defined for struct inputs
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have an input argument that is a 1x1 struct
this is my code
function escrevecircuitos(circuito, fid)
if fid == 1 fprintf(fid,'%8s %13s %2s %2s %9s %7s\r\n', 'circuito', 'nome_ficheiro', 'SE', 'ID', 'Perimetro', 'Recorde'); for i = 1:length(circuito) fprintf('%20s %14.1s %2.6f %1.6f %2.6f %1.6f %4d %1:2:3f\r\n',circuito(i).circuito,circuito(i).nome_ficheiro,circuito(i).SE(1),circuito(i).ID,circuito(i).Perimetro,circuito(i).Recorde); end end
How can i solve the problem,the error is
Error using fprintf Function is not defined for 'struct' inputs.
Error in escrevecircuitos (line 7) fprintf('%20s %14.1s %2.6f %1.6f %2.6f %1.6f %4d %1:2:3f\r\n',circuito(i).circuito,circuito(i).nome_ficheiro,circuito(i).SE(1),circuito(i).ID,circuito(i).Perimetro,circuito(i).Recorde)
Thank you for the help
0 Kommentare
Antworten (1)
Walter Roberson
am 5 Dez. 2013
That looks okay at the moment, unless one of the fields inside circuito is itself a structure. Perhaps circuito(i).circuito or circuito(i).Perimetro
Try this to help debug
fn = fieldnames(circuito);
for K = 1 : length(circuito)
for f = 1 : length(fn)
if isstruct( circuito(K).(fn{f}) )
fprintf('Index %d field %s is structure\n', K, fn{f} );
end
end
end
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!