필터 지우기
필터 지우기

Problem with Subplot "Error using subsindex"

조회 수: 1 (최근 30일)
carlos Uribe
carlos Uribe 2013년 3월 1일
댓글: William Chamberlain 2018년 10월 22일
I'm writing a code to plot several subplots in a figure...to simplify it it looks something like this:
h1=subplot(3,2,1);
plot(x,y)
set(h1,'XTickLabel',{'A','B'},'YTick',[1 2 3],'FontSize',12,'FontWeight','Bold')
This works fine, I finish the different subplots in this figure...
Then I open a second figure and try the same thing:
figure;
h2=subplot(3,2,1);
plot(x2,y2);
set(h2,'XTickLabel',{'C','D'},'YTick',[4 5 6],'FontSize',12,'FontWeight','Bold')
In this case I get the error:
Error using subsindex
Function 'subsindex' is not defined for values of class 'cell'.
What do I need to do to make it work? why does it work for the first figure (first subplot of first figure to be specific) but it gives me trouble when I try to do the same thing on the second one?
Any help is appreciated...Thanks.

채택된 답변

Walter Roberson
Walter Roberson 2013년 3월 1일
You could get that error if somehow in-between those two, "set" had become a variable, so it thought everything in your () were indices into "set".
  댓글 수: 3
Nishant Kumar
Nishant Kumar 2015년 9월 14일
편집: Nishant Kumar 2015년 9월 14일
Thanks for the Q&A.
William Chamberlain
William Chamberlain 2018년 10월 22일
Alsow worked for me, thanks: I had managed to create a variable named 'axes' which was giving me problems with
sub_axis_h(3) = subplot(2,2,3);
axes(sub_axis_h(1)); hold on; grid on; xlabel('x'); ylabel('y');

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by