Plotting issues with labeling axis and giving titles

조회 수: 4 (최근 30일)
Austin Duncan
Austin Duncan 2019년 4월 23일
답변: Adam Danz 2019년 4월 23일
I have commented out the titles and labels as the program runs fine without them but when i uncomment them it still graphs but gives and Index exceds array bounds and dosnt label or title the graph. pls help
R_A1 = -2250;
R_P1 = 3750;
% Plot for shear force
x_beam = 0:.1:5; %length of beam
syms x
y = piecewise(x<2, R_A1, 2<=x<5, R_A1 + R_P1, x ==5,0)
subplot(3,2,1)
% title('Shear Force Diagram')
% xlabel('distance along beam (m)')
% ylabel('Shear Force (N)')
fplot(y)
xlim([0 5])
ylim([-2500 2500])
  댓글 수: 2
Adam Danz
Adam Danz 2019년 4월 23일
편집: Adam Danz 2019년 4월 23일
No error when I run it. However, you must move the calls to title(), xlabel(), and ylabel() to after fplot() --or-- include the handle to the subplot axes as the first input to fplot().
Please provide the full copy-pasted error message.
Austin Duncan
Austin Duncan 2019년 4월 23일
this is the response even after the code is moved until after fplot()
Index exceeds array bounds.
Error in Diving_Board_MD (line 33)
title('Shear Force Diagram')

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

답변 (2개)

Walter Roberson
Walter Roberson 2019년 4월 23일
You accidentally created a variable named title which is interfering with calling the function named title

Adam Danz
Adam Danz 2019년 4월 23일
My hunch is that 'title' is a variable in your data and no longer represents matlab's builtin function of the same name.
This reproduces your error:
title = 123456;
title('Shear Force Diagram')
% result:
error: Index exceeds array bounds.
To confirm this,
which title
If title is a variable you'll see: title is a variable.
If title is matlab's function you'll see something like:
C:\Program Files\MATLAB\R2019a\toolbox\matlab\graph2d\title.m
Solution: don't use "title" as a variable name.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by