Function figure has the same name as a MATLAB builtin mistake

3 次查看(过去 30 天)
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

回答(2 个)

Andreas Goser
Andreas Goser 2014-11-18
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 个评论
JIAWEI WU
JIAWEI WU 2014-11-18
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.

请先登录,再进行评论。


John D'Errico
John D'Errico 2014-11-18
编辑:John D'Errico 2014-11-18
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 个评论
JIAWEI WU
JIAWEI WU 2014-11-18
编辑:JIAWEI WU 2014-11-18
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 2014-11-19
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by