Yes, this would be almost the same code:
obj=struct();
obj.a=1;
obj.b=2;
obj.c=3;
tmp=fieldnames(obj);
for i=1:3
disp(obj(tmp(i)));
end
in Scilab fieldnames yields an array of strings (not a cell array) and struct
indexing by a string is simpler (the dot is not needed).
S.
On 4/8/24 13:55,
Hello,
Is it possible to do the same as this matlab code in scilab ?
thank you in advance
obj=struct();
obj.a=1;
obj.b=2;
obj.c=3;
tmp=fieldnames(obj);
for i=1:3
disp(obj.(tmp{i}));
end
Guylaine Collewet
[cid:image001.png@01DA89BC.68CB93C0]
ingénieur de recherche équipe