How to plot a string signal/array?
Hi all,
In Simulink, I’m using String Signals to represent internal states for my systems. For example:
mySignal is a string signal, and not a numeric one. I log it into the base workspace inside the simout variable, and I also send it to the Simulation Data Inspector.
Inside the Simulation Data Inspector, this string signal is neatly displayed, like this :
The string values are displayed as colored patches, evolving with the simulation time.
This visualization method for string signals is great, but I can’t find a way to do something similar in MATLAB. Once my string signal is inside a base workspace variable, I try to plot it just like a regular signal, but it doesn’t work:
>> simout
simout =
struct with fields:
time: [1001×1 double]
signals: [1×1 struct]
blockName: ‘plot_string_signals/To Workspace’
>> simout.signals
ans =
struct with fields:
values: [1001×1 string]
dimensions: 1
label: ‘mySignal’
>> plot(simout.time, simout.signals.values)
Error using plot
Invalid data argument.
So my question is: how to plot a string datatype signal/array in MATLAB? Is there a dedicated plotting function for this use case that I don’t know ? I expected the plot function to provide the same kind of graph as the Simulation Data Inspector, but was disappointed.
(I’m using MATLAB 22b Update 8)
Thanks,
SeiganHi all,
In Simulink, I’m using String Signals to represent internal states for my systems. For example:
mySignal is a string signal, and not a numeric one. I log it into the base workspace inside the simout variable, and I also send it to the Simulation Data Inspector.
Inside the Simulation Data Inspector, this string signal is neatly displayed, like this :
The string values are displayed as colored patches, evolving with the simulation time.
This visualization method for string signals is great, but I can’t find a way to do something similar in MATLAB. Once my string signal is inside a base workspace variable, I try to plot it just like a regular signal, but it doesn’t work:
>> simout
simout =
struct with fields:
time: [1001×1 double]
signals: [1×1 struct]
blockName: ‘plot_string_signals/To Workspace’
>> simout.signals
ans =
struct with fields:
values: [1001×1 string]
dimensions: 1
label: ‘mySignal’
>> plot(simout.time, simout.signals.values)
Error using plot
Invalid data argument.
So my question is: how to plot a string datatype signal/array in MATLAB? Is there a dedicated plotting function for this use case that I don’t know ? I expected the plot function to provide the same kind of graph as the Simulation Data Inspector, but was disappointed.
(I’m using MATLAB 22b Update 8)
Thanks,
Seigan Hi all,
In Simulink, I’m using String Signals to represent internal states for my systems. For example:
mySignal is a string signal, and not a numeric one. I log it into the base workspace inside the simout variable, and I also send it to the Simulation Data Inspector.
Inside the Simulation Data Inspector, this string signal is neatly displayed, like this :
The string values are displayed as colored patches, evolving with the simulation time.
This visualization method for string signals is great, but I can’t find a way to do something similar in MATLAB. Once my string signal is inside a base workspace variable, I try to plot it just like a regular signal, but it doesn’t work:
>> simout
simout =
struct with fields:
time: [1001×1 double]
signals: [1×1 struct]
blockName: ‘plot_string_signals/To Workspace’
>> simout.signals
ans =
struct with fields:
values: [1001×1 string]
dimensions: 1
label: ‘mySignal’
>> plot(simout.time, simout.signals.values)
Error using plot
Invalid data argument.
So my question is: how to plot a string datatype signal/array in MATLAB? Is there a dedicated plotting function for this use case that I don’t know ? I expected the plot function to provide the same kind of graph as the Simulation Data Inspector, but was disappointed.
(I’m using MATLAB 22b Update 8)
Thanks,
Seigan plot, string MATLAB Answers — New Questions