Function figure has the same name as a MATLAB builtin mistake
1 view (last 30 days)
Show older comments
I wrote the code as following:
-------------------------------------------
att_phi = figure('Name','attitude X axis','NumberTitle','off');
stairs(sim_eul.time, sim_eul.signals.values(:,1),'color','r','LineWidth',2);
hold on
stairs(att_obs_attitude.time,att_obs_attitude.signals.values(:,1),'color','b','LineWidth',2);
hold off
title('phi angle ','fontsize',fontsizeT)
legend('simulated','estimated')
ylabel('Angle [rad]','fontsize',fontsize)
xlabel('Time [s]','fontsize',fontsize)
grid on
-------------------------------------------
Mistake message : 'Name' is an invalid option
-------------------------------------------
Matlab version: Matlab 2014b
Problem:
1. Why is the property name wrong?
2. Is there anything wrong inside that piece of code?
Thx.
Jiawei
0 Comments
Answers (2)
Andreas Goser
on 18 Nov 2014
I do not think you do something wrong. When I execute with reasonable data, it runs through:
att_phi = figure('Name','attitude X axis','NumberTitle','off');
sim_eul.time=[1 2 3 4];
att_obs_attitude.time=sim_eul.time;
sim_eul.signals.values=[1 2 3 4;1 2 3 4]';
att_obs_attitude.signals.values=sim_eul.signals.values;
fontsizeT=12;
fontsize=12;
stairs(sim_eul.time, sim_eul.signals.values(:,1),'color','r','LineWidth',2);
hold on
stairs(att_obs_attitude.time,att_obs_attitude.signals.values(:,1),'color','b','LineWidth',2);
hold off
title('phi angle ','fontsize',fontsizeT)
legend('simulated','estimated')
ylabel('Angle [rad]','fontsize',fontsize)
xlabel('Time [s]','fontsize',fontsize)
grid on
4 Comments
John D'Errico
on 18 Nov 2014
Edited: John D'Errico
on 18 Nov 2014
You both seem to be focusing on the idea of Name as a function. That does not seem to be indicated by your comments, nor by the error message you got.
The title of your post is "Function figure has the same name as a MATLAB builtin mistake".
That suggests to me that you have written a function whos name is figure.m, and put it on your search path. That it works on a different release merely indicates you did not port over this spurious figure.m function to the alternate release.
So my question would be to ask what you get from
which figure -all
If you created your own figure function, then it would overload the built-in figure, and cause the error you indicate.
2 Comments
Andreas Goser
on 19 Nov 2014
As opposed to me, John read carefully the title line. But in both cases, it would help to execute the "which" command instead of just claiming there is no "figure.m". What abould "figure" for a P file? A variable? Etc.
See Also
Categories
Find more on Graphics Performance 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!