MATLAB cannot plot LinearModel: "Unable to perform assignment because dot indexing is not supported for variables of this type."

3 Ansichten (letzte 30 Tage)
I created a LinearModel alpha_Approx (see attachment) by using fitlm function on a set of measured data points.
When I try to plot the result
plot(alpha_Approx);
Unrecognized function or variable 'alpha_Approx'.
I get the following error. It seems the error has something to do with "title" and not the data itself. Plus, when "Pause on error" was turned on, the workspace shows that the value of variable "this" is a complex number 0+0i.
How can I get rid of this error?
Unable to perform assignment because dot indexing is not supported for variables of this type.
Error in ctrluis.axesgroup/addbypass>localTitle (line 24)
this.Title = string;
Error in mwbypass (line 17)
hh = feval(fcn{:},varargin{:});
Error in title (line 75)
h = mwbypass(ax,'MWBYPASS_title',titlestr,pvpairs{:});
Error in LinearModel/plotxy (line 736)
title(ax,sprintf('%s',getString(message('stats:LinearModel:sprintf_AvsB',yname,xname))),'Interpreter','none');
Error in LinearModel/plot (line 56)
h = plotxy(lm,varargin{:});
>> plot(beta_Approx_Volleingriff)
Unable to perform assignment because dot indexing is not supported for variables of this type.
Error in ctrluis.axesgroup/addbypass>localTitle (line 24)
this.Title = string;
Error in mwbypass (line 17)
hh = feval(fcn{:},varargin{:});
Error in title (line 75)
h = mwbypass(ax,'MWBYPASS_title',titlestr,pvpairs{:});
Error in LinearModel/plotxy (line 736)
title(ax,sprintf('%s',getString(message('stats:LinearModel:sprintf_AvsB',yname,xname))),'Interpreter','none');
Error in LinearModel/plot (line 56)
h = plotxy(lm,varargin{:});

Akzeptierte Antwort

Star Strider
Star Strider am 10 Feb. 2022
I have no idea what the rest of your code looks like, however I have no problem plotting it:
This code:
LD = load('alpha_Approx.mat');
alpha_Approx = LD.alpha_Approx;
figure
plot(alpha_Approx)
grid
produces this plot:
Check to be certain the model is in your workspace and that plot has access to it. Remember that functions have their own workspaces and will not share their outputs with the calling workspace unless they are specifically requested in the call to the function. The only situations I can think of (just now at least) is that ‘alpha_Approx’ is inside a function and the plot call is in the calling workspace and the model was not returned as an output from the function, or the reverse, that being that the model exists in the calling workspace, the plot call is inside a function, and the model was not passed to the function as an argument.
.
  2 Kommentare
DFfd
DFfd am 11 Feb. 2022
Thanks for the info. I added figure before plotting and it worked well. I guess that the problem comes from some already closed previous figures (bode plots) stored in my workspace which messed up with the plot command.
figure;
plot(alpha_Approx);
Unrecognized function or variable 'alpha_Approx'.
Star Strider
Star Strider am 11 Feb. 2022
As always, my pleasure!
Declaring a new figure is necessary (and something I always do) because that creates a new figure window and axes. Otherwise, the new plot attempts to plot in an existing figure window on the existing axes and replaces whatever was originally plotted (unless the hold condition is toggled 'on' and in that situation the subsequent plot call adds the plot to the existing axes).
The Control System and System Identification Toolbox plotting functions such as bode don’t play by the normal rules for plots. They have their own rules. That occasionally creates problems.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by