Why do I keep getting this error for subplot? Am I missing a toolbox or is the code wrong?

조회 수: 2 (최근 30일)
Error using subplot
Unknown command option.
Error in (line 136)
h = subplot(2,1,[.12 .08],[.10 .08],[.12 .02])
  댓글 수: 2
VBBV
VBBV 2023년 3월 17일
편집: VBBV 2023년 3월 17일
Do you want the subplot spacing to be more compact ? or working with the below custom function ?https://in.mathworks.com/matlabcentral/fileexchange/27991-tight_subplot-nh-nw-gap-marg_h-marg_w
if so, then you need to call that function as given in instruction
[ha, pos] = tight_subplot(2,1,[.12 .08],[.10 .08],[.12 .02])
Isabella Sciullo
Isabella Sciullo 2023년 3월 17일
figure(2)
[ha, pos] = tight_subplot(2,1,[.12 .08],[.10 .08],[.12 .02]);
axes(ha(1)); box on; plot(angle0,Cp_exact,'b',beta,Cp,'r^');
grid; legend('C_p (exact)', 'C_p (SPM)');
title(['Fig. 2 Comparison of C_p and V_s (n = ' num2str(n) ', R = ' num2str(R) 'm)']);
xlim([0 2*pi]); set(gca,'xtick',0:pi/2:2*pi);
set(gca,'xticklabel',{'0','\pi/2','\pi','3\pi/2','2\pi'});
xlabel('\beta'); ylabel('C_p')
axes(h(2)); box on; plot(angle0,(Vs_exact),'b',beta,(Vs),'r^');
grid; legend('V_s (exact)', 'V_s (Source panel method)');
xlim([0 2*pi]); set(gca,'xtick',0:pi/2:2*pi);
set(gca,'xticklabel',{'0','\pi/2','\pi','3\pi/2','2\pi'});
xlabel('\beta'); ylabel('V_s [m/s]')
I'm not sure if I set it up right but

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

답변 (1개)

Jan
Jan 2023년 3월 17일
Please read the documentation of the command: subplot or
doc subplot
You call this command like subplot(m,n,p), where m and n are the numbers of rows and columns, and p is the index of the subplot.
What do you expect the input [.12 .08],[.10 .08],[.12 .02] to do?

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by