Function figure has the same name as a MATLAB builtin mistake

3 views (last 30 days)
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

Answers (2)

Andreas Goser
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
JIAWEI WU
JIAWEI WU on 18 Nov 2014
Oh, i am so sorry, my colleague has already helped me replace the version 2014b to 2014a after the fact that he also can't solve the problem. But i will attach the message obtained after execute 'which name -all' from my pc at home later. Because i am using 2014b on my personal pc.
Thx anyway.

Sign in to comment.


John D'Errico
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
JIAWEI WU
JIAWEI WU on 18 Nov 2014
Edited: JIAWEI WU on 18 Nov 2014
Thanks for your reply.
in fact, there is no particular function sounds like 'figure.m', i guess it indicates the system function 'figure(property name, value....)'.
By the way, even I only execute command 'figure('Name','nothing')', it will also propose the message: 'Name' is invalid option. and warning like, there is conflict with system built-in function while using 'figure('Name',....)'.
Andreas Goser
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.

Sign in to comment.

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!