Function figure has the same name as a MATLAB builtin mistake
조회 수: 1 (최근 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
댓글 수: 0
답변 (2개)
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
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
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 Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!