print multiple lines to textarea
Mostrar comentarios más antiguos
app.TextArea.Value=sprintf('Fourier Number of Terms:%d\n\nEquation:\ny=a0',n);
for i=1:n
txt='+a%d cos(%dx)+b%d sin(%dx)';app.TextArea.Value=(sprintf(txt,i,i,i,i));
end
app.TextArea.Value=sprintf('\nCoefficients:\na0=%.4f',a0);
for i=1:n; app.TextArea.Value=sprintf('\na%d=%.4f \nb%d=%.4f',i,a(i),i,b(i)) ;
end
app.TextArea.Value=sprintf('\n\nJ=%.4f \n\nR^2=%.4f \n\nRMSE=%.4f',j1,rsq1,RMSE1);
if i run this code it only prints last sprintf output, how do i print all

like this one
Respuesta aceptada
Más respuestas (1)
Benjamin Thompson
el 15 de Feb. de 2022
1 voto
Can you combine the outputs of all your sprintf calls into a single string, and pass this to app.TextArea.Value? It is not clear what app.TextArea.Value from your code, but my guess is that every time you assign something new to app.TextArea.Value, the previous information is deleted.
>> S1 = sprintf("My first string has number %d\n", 3)
S1 =
"My first string has number 3
"
>> S2 = sprintf("My second string has name %s\n", "Billy")
S2 =
"My second string has name Billy
"
>> S3 = strcat(S1, S2)
S3 =
"My first string has number 3
My second string has name Billy
"
1 comentario
Fransi Mittal
el 15 de Feb. de 2022
Categorías
Más información sobre Low-Level File I/O 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!