MATLAB Answers

Undefined function 'updateSystem' for input arguments of type 'matlab.ui.Figure'.

6 views (last 30 days)
Line 1: h = filterPlot(trip,0,18,1,2000,machMap,20,110);
Line2: updateSystem(h,filterPlot(trip,0,18,1,2000,machMap,25,110));
I am using above two lines of code to update my figure with new inputs. and I get the above error.
First line gives me a figure using my filterPlot function. I want to update the same figure with new input values. But when I execute second line, It throws above error and gives updated figure in new window.
I am using Matlab R2017b version.
I have my "fliterPlot" function attached. Any suggestions?

  1 Comment

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 19 Nov 2019
Your filterPlot function returns the handle to a MATLAB figure. According to its documentation page updateSystem requires its first input to be the "Plot to update with new system data, specified as a plot handle. Typically, you obtain the plot handle as an output argument of a response plotting command such as stepplot or bodeplot. For example, the command h = bodeplot(G) returns a handle to a plot containing the Bode response of a dynamic system, G."
If you're modeling your code after this documentation page note that the first input to updateSystem in the callback is h (the output of stepplot) not f (the output of figure).
If you can describe in more detail specifically how you want your figure and its contents to be updated, we may be able to offer guidance for how to update them.


niranjan nuthalapati
niranjan nuthalapati on 19 Nov 2019
Thanks for Response steven. I just figured exactly what you said, while I was trying to dig deep.
Each line in the subplot corresponds to a data set. so if i plot all the data sets in my "trip", its get too crowded. So I am filtering them through velocity, distance etc.
If I plot all the data in my "trip" structure withought any if conditions inside forloop, this is how it looks. Because it has some 1000+ loops in the structure
Now I want reduce the loops by adding those if conditions, so that my plot looks less dense like this, now what I did here is filtering for loops between 20-30(just example). Or I want to filter based on starting velocity of loop. end distance of loop. etc.
Second pictue is less crowded I can compare easily. I can also have less crowded legends.
Hope I made my requirements more clear. I am also attaching my "trip" Data set.
Any suggestions in this regard?
My questions would be, Should I return handles of subplot in filterplot i.e., h3,h4. If I return them, will the whole gets updated, when I call them from updateSystem?
Thank you
Steven Lord
Steven Lord on 19 Nov 2019
If you're storing the handles of the lines that you create in a vector of handles, you could change the Visible property of a subset of them to control which ones are visible.
% Create some sample data and set up the axes and the vector of handles
x = 0:0.1:2*pi;
axis([0, 2*pi, -1, 1])
hold on
h = gobjects(1, 5);
% Plot five curves and show the legend associated with the curves
for k = 1:5
h(k) = plot(x, sin(k*x), 'DisplayName', "sin(" + k + "*x)");
legend show
pause % so you can see all five curves
% Make the 1st and 3rd curves invisible and update the legend
set(h([1 3]), 'Visible', 'off');
legend show
% Only show the visible lines in the legend
legend(h([2 4 5]))
In this simple example, I chose which curves to make invisible. You could compute the vector [1 3] of curves to make invisible however you want.
% Turn them all back on
set(h, 'Visible', 'on');
% Make the curves corresponding to even values of k disappear
toDisappear = mod(1:5, 2) == 0;
set(h(toDisappear), 'Visible', 'off')
% Make the curves corresponding to prime values of k disappear
set(h, 'Visible', 'on');
set(h(isprime(1:5)), 'Visible', 'off')
niranjan nuthalapati
niranjan nuthalapati on 19 Nov 2019
But complexity here I have is, two subplots. I want both of them to reflect the change when call through updateSystem. If it is single plot as your code shows, I can return directly that plot handle in "filterPlot" function and use it in updateSystem.

Sign in to comment.

More Answers (0)

Sign in to answer this question.