필터 지우기
필터 지우기

Function figure has the same name as a MATLAB builtin mistake

조회 수: 1 (최근 30일)
JIAWEI WU
JIAWEI WU 2014년 11월 18일
댓글: Andreas Goser 2014년 11월 19일
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
Andreas Goser
Andreas Goser 2014년 11월 18일
What does
which name -all
return for you?
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