How can I use fprintf to display a message in a text box in a GUIDE GUI?

Hello, Im trying to build a results box into my gui.
Why will this code not display ‘Member F1 has not failed, with a final load of “value from the defined matrix” Newtons'?
% The results textbox must show the results for F1
message = fprintf('Member F1 has not failed, with a final load of %5.2f Newtons \n' , handles.matrix_X(1,end));
set(handles.results, 'string', 'message');
All that the text box displays is ‘message’. Please note that there is no line break in the 'message =' code, that is just the way it has copied and pasted.

 Accepted Answer

Ok I have fixed it. I changed 'message' to 'handles.message' in both cases, and I used sprint instead of fprintf.

More Answers (1)

See
doc fprintf
for the "why". What does it say fprintf returns if there is an output variable given? (HINT: it isn't the same as what is written).
doc sprintf % probably will lead to more joy instead...

Categories

Asked:

on 23 Mar 2015

Answered:

dpb
on 23 Mar 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!