- Your callback code that responds to the signal selection should use addsignal for the selected parameter and removesignal for the alternate so only the one is actually connected, or
- Fake it by setting the linestyle color for the alternate to the background color of the axes so it isn't visible when not selected and reset the color to display the selected.
How can I remove a line off UIAxes on App designer in RealTime with SpeedGoat
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
Im creating an app using App designer and Simulink in Realtime with a speedgoat. I have a drop down menu that has a selection of position or velocity. Depending on what is selected I want to plot it on a UIaxes. However, for instance, when I go from velocity to poisition or vice versa, The graph keeps both lines on the UIAxes. I only need to show one line that corresponds to the value of the dropdown list. Im using connectline() command to plot. I tried using clearScalarAndLineData() command to clear the axes but it is not working. My issue is that I cannot get rid of a line once I use the connectline() command. I also tried using cla() but once I use it, it will not replot during the simulation.
My desire is to have when the dropdown list equals to position, the UIaxes will plot only the position signal and when the dropdown list equals velocity, it will only plot the velocity signal during simulation.
Here is my code so far
function PlotSelectValueChanged(app, event)
value = app.PlotSelect.Value;
if value == "Position"
app.Instrument = slrealtime.Instrument(app.SLRTApp);
addInstrumentedSignals(app.Instrument)
app.Instrument.connectLine(app.DataPlotAxes,"Pos_AX1");
app.Instrument.AxesTimeSpan = 10;
app.Instrument.AxesTimeSpanOverrun = 'wrap';
app.InstrumentManager = slrealtime.ui.tool.InstrumentManager(app.BenchTopUIFigure, 'TargetSource', app.TargetSelector);
app.InstrumentManager.Instruments = app.Instrument;
elseif value == "velocity"
app.Instrument = slrealtime.Instrument(app.SLRTApp);
addInstrumentedSignals(app.Instrument)
app.Instrument.connectLine(app.DataPlotAxes,"Vel_AX1");
app.Instrument.AxesTimeSpan = 10;
app.Instrument.AxesTimeSpanOverrun = 'wrap';
app.InstrumentManager = slrealtime.ui.tool.InstrumentManager(app.BenchTopUIFigure, 'TargetSource', app.TargetSelector);
app.InstrumentManager.Instruments = app.Instrument;
end
end
Thanks
0 comentarios
Respuestas (1)
dpb
el 20 de Jul. de 2024
Editada: dpb
el 20 de Jul. de 2024
I "know nuthink!" about Simulink but looks to me like clearScalarAndLineData just clears the present data but since the signals are both connected after you've selected the other besides the initial default, they would do as you observe; both continue to plot.
It would seem there should be a complementary disconnectLine method to allow you to do so, but doesn't appear to be one. Failing that, one would expect a handle to the line object would be returned that could delete, but that doesn't appear possible, either.
Again, I have never even seen Simulink, what more used it, so this is all conjecture, but it would appear you have two choices --
I have no idea if the first option will actually work or not, but it would seem to be the only way from the documented functions I can find that wouldn't leave both connected since there doesn't appear to be a way to disconnect the line itself.
I would say this would warrant an official support/bug request to Mathworks if neither of the above brings joy...
0 comentarios
Ver también
Categorías
Más información sobre Target Computer Setup 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!