Effacer les filtres
Effacer les filtres

How can I remove a line off UIAxes on App designer in RealTime with SpeedGoat

24 vues (au cours des 30 derniers jours)
Ethan
Ethan le 19 Juil 2024 à 17:43
Modifié(e) : dpb le 20 Juil 2024 à 14:20
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

Réponses (1)

dpb
dpb le 20 Juil 2024 à 14:08
Modifié(e) : dpb le 20 Juil 2024 à 14:20
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 --
  1. 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
  2. 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.
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...

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by