Creating a table of every iteration from a for loop
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I would like to have every iteration from a for loop into one table. My code is currently outputting fifty two 1x3 tables, but I want one 52x3 table. Currently my code looks like this:
for i:52
MaximumError = max(weather)
MinimumError = min(weather)
AverageError = mean(weather)
figure
T = table(MaximumError(:), MinimumError(:), AverageError(:));
TString = evalc('disp(T)');
TString = strrep(TString,'<strong>','\bf');
TString = strrep(TString,'</strong>','\rm');
TString = strrep(TString,'_','\_');
FixedWidth = get(0,'FixedWidthFontName');
annotation(gcf,'Textbox','String',TString,'Interpreter','Tex','FontName',FixedWidth,'Units','Normalized','Position',[0 0 1 1]);
end
Also, how do I label the columns Maximum, Minimum, Average?
0 comentarios
Respuestas (1)
Walter Roberson
el 11 de Feb. de 2018
You over overwriting all of your three variables each time through the loop. Instead of doing that, assign the output to the variable indexed with (i) in the loop, and put all of the processing of the displaying after the loop.
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!