How to display struct along filed?

2 visualizzazioni (ultimi 30 giorni)
msahar
msahar il 13 Feb 2015
Risposto: Rajanya il 11 Mar 2025
step info of any transfer function is displayed like this,
S = RiseTime: 6.2550e-06, SettlingTime: 4.8543e-04, Overshoot: 85.3868, PeakTime: 2.0384e-05,
i want to display this whole information in msgbox as string or in static box in GUI. Is there any way to display it in msgbox or static box ??
Please help.

Risposte (1)

Rajanya
Rajanya il 11 Mar 2025
Assuming 'S' is a structure with the given fieldnames and values, you can loop through the structure and create the required string (maybe, using sprintf), which can then be displayed in a message box using 'msgbox' function of MATLAB.
For example,
fields = fieldnames(S); %get the field names
for i=1:length(fields)
fieldName = fields{i};
fieldValue = S.(fieldName);
%str = create the required string with the extracted fieldName and fieldValue
...
end
% at this point, 'str' contains the whole string
msgbox(str)
Hope this helps.
Thanks!

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by