why i am getting "Ambiguous property found while using line" error?

i am trying to draw a line from the accelerometer data.. code is as shown below
[gx,gy,gz] = readAcc(accelerometer);
disp(gx);
line([0 gx],[0 0],'Color','r','LineWidth',2,'Marker','o');
but i am getting error as
Error using line
Ambiguous property found.
Object Name : line
Property Name : ''.
Error in vector (line 45)
line([0 gx],[0 0],'Color','r','LineWidth',2,'Marker','o');
what might be the cause and how to resolve this problem? it does not display any property name..

 채택된 답변

Try the full
line('XData', [0 gx], 'YData', [0 0],'Color','r','LineWidth',2,'Marker','o');

댓글 수: 7

Thanks for your reply but after trying as you said i am getting error like
Error using line Value must be numeric
Error in vector (line 46)
line('XData', [0 gx], 'YData', [0 0],'Color','r','LineWidth',2,'Marker','o');
which value i need to change
ya you are correct, i just modified that code like this
function [gx,gy,gz] = readAcc(out)
fprintf(out.s,'R');
accData1=fscanf(out.s,'%s');
accData2=fscanf(out.s,'%s');
accData3=fscanf(out.s,'%s');
gx=accData1;
gy=accData2;
gz=accData3;
disp(gx);
and even disp(gx) also not working i guess
i verified my code and found that gx ='' when i run readAcc for the first time and for the second time gx is numeric value i.e 1.00.. so what should i do now? how to neglect string which is coming for the first time and consider from the second time?
You are returning string values, not numeric values. You cannot use string values to plot with, not without converting them to numeric values. Which is what the %u format was for, to convert the string to numeric values.
Why did you change from %u to %s? If your input values have changed from unsigned integer to floating point, use %f not %s
That worked...thank you very much..
hello Walter Roberson, sorry for asking so many questions again and again, i am encountered another error.. i have 2 .m files readAcc.m and vector.m.. in command window if i type
[accData1 accData2 accData3]=readAcc(accelerometer)
i get as accData1 = 1.0100
accData2 = -0.0400
accData3 = -0.2700
but when i run vector.m file which has function call as [accData1 accData2 accData3] = readAcc(accelerometer); after that function call if put disp(accData1); i get as 51__ or something like that.. why is like that?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2016년 1월 29일

댓글:

2016년 1월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by