Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Error is coming how can I solve?

조회 수: 1 (최근 30일)
RS
RS 2013년 8월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
Cell contents reference from a non-cell array object.
Error in Mineral_2 (line 12)
line([A(xmaxA) A(xmaxA)], [limh(1) max(A(:,2))], 'color', chrom{1},'Linestyle',':')

답변 (3개)

Caroline
Caroline 2013년 8월 23일
Could you post the code? It could be because you used {} instead of () to access the element of an array but its hard to say without seeing the code.
  댓글 수: 1
RS
RS 2013년 8월 23일
편집: RS 2013년 8월 23일
h=plot(A(:,1),A(:,2));
ymaxA=max(A(:,2));
xmaxA=find(A(:,2)==max(A(:,2)));
xA0=A(A(:,2)==0);
limh=get(gca,'Ylim');
chrom=get(h,'color');
line([A(xmaxA) A(xmaxA)], [limh(1) max(A(:,2))], 'color', chrom(1),'Linestyle',':');
again some error are coming here how can I improve?

Image Analyst
Image Analyst 2013년 8월 23일
편집: Image Analyst 2013년 8월 23일
Before that line, put these lines:
whos chrom
chrom{1}
Tell us what it says. Then look at this link: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/

Walter Roberson
Walter Roberson 2013년 8월 23일
You make chrom a cell array. Somehow it is not one at the moment in your code.
  댓글 수: 5
Image Analyst
Image Analyst 2013년 8월 24일
You need to have the same number of x values as y values, and you need, need, need to learn basic debugging skills. Is B an integer array, so that you might have multiple locations for xmaxA? What can you learn from doing this:
xValues = [A(xmaxA) A(xmaxA)]
size(xValues)
yValues = [limh(1) max(A(:,2))]
size(yValues)
Walter Roberson
Walter Roberson 2013년 8월 24일
You still need the keyword 'color'
line([A(xmaxA) A(xmaxA)], [limh(1) max(A(:,2))], 'color', chrom,'Linestyle',':');

Community Treasure Hunt

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

Start Hunting!

Translated by