Semi colons aren't suppressing output
Mostrar comentarios más antiguos
I have this as part of my code, i try to suppress as the output takes a while to finish, but semi colons aren't working
SECTIONS={'Joints','Model','Segments','Trajectories'}; % the looked for data sections
ich=find(cellfun(@ischar,G(:,1))); % the records that have char() data first column
isec=ich(contains(G(ich,1),SECTIONS)); % the locations of each section beginning
isec=[isec;size(G,1)+2]; % add last line for indexing sections first:last lines
for i=1:numel(SECTIONS);
vn=string(G(isec(i)+3,:));
in=find(ismissing(vn));
vn(in)="Var"+in;
cmd=sprintf('t%s=cell2table(G(isec(%d)+5:isec(%d)-2,:))',SECTIONS{i},i,i+1);
eval(cmd);
end
4 comentarios
Stephen23
el 10 de Jun. de 2022
"but semi colons aren't working"
You forgot to put a semi-colon at the end of the text that you EVAL.
Note that using a structure or cell array would be simpler, more reliable, and more efficient than using EVAL:
Jak
el 10 de Jun. de 2022
Stephen23
el 10 de Jun. de 2022
"where do you mean?"
At the end of the text that you EVAL: is there a semi-colon? Answer: no.
"There is a semi colon on the end of each line"
Sure, but that is not the problem.
"or do i need it elsewhere?"
Yes, at the end of the text that you provide to EVAL.
Note that using a structure or cell array would be simpler, more reliable, and more efficient than using EVAL:
Peter Perkins
el 13 de Jun. de 2022
I mean, the bigger thing is, "don't do that". You are creating vars in your workspace using sprintf and eval. There are lots of posts about why that is not a good thing.
That whole line of code, with the exception of the LHS of the assignment, can be written as literal code, using i as a subscript. And if you assign to a field of a scalar struct as mydata.(['t' SECTIONS{i}]), you can get rid of the eval.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Simulink 3D Animation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!