unexpected matlab operator error when plotting from a simulink matlab function
4 views (last 30 days)
Show older comments
Hi to everyone,
I have a matlab function called from simulink and I'm trying to plot all the elements of a vector, but unexpected matlab operator error appears.
My aim is to build a vector adding [u,u] at each step (like vector=[vector;x]) and then plot it at the end of each step.
I don't know why it doesn't accept the ":" in the plot.
The code is:
coder.extrinsic('evalin', 'assignin', 'plot')
Does anyone know how to fix it?
Paul on 19 Jan 2023
Are you really trying to plot u vs. u? Wouldn't that just be a straight line?
If I understand what you're trying to do, would the XY Graph be applicable?
If wanting to do this in a Matlab Function, this code worked for me. It seems simpler and doesn't have to work with the base workspace.
% Incrementally add points to a line plot of t vs u
persistent init hline
init = 1;
hline = line(gca,t,u);
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!