Please why does this code give an error "Index in position 2 exceeds array bounds. Index must not exceed 6"

1 view (last 30 days)
Please why does this code give an error "Index in position 2 exceeds array bounds. Index must not exceed 6"
For line
plot (time, strain(:, [6,7]
figure(2)
sgtitle('Strain Comparison')
subplot(3,1,1);
plot(time, strain(:,[6,7]))
xtickformat('HH:mm:ss')
legend('Longitudinal','Transverse','Location','northwest')
xlabel('Time');
ylabel('Subbase Strain');
title('Control')
ylim([-800,200]); % put a '%' in front of it.
subplot(3,1,1);
plot(time,strain(:,[10,11]))
xtickformat('HH:mm:ss')
legend('Longitudinal','Transverse','Location','northwest')
xlabel('Time');
ylabel('Subbase Strain');
title('LCC400')
ylim([-200,200]); % put a '%' in front of it.
subplot(3,1,3);
plot(time,strain(:,[12,13]))
xtickformat('HH:mm:ss')
legend('Control','LCC400','Location','northwest')
xlabel('Time');
ylabel('Surface Strain');
title('Longitudinal Strain')
ylim([-300,200]); % put a '%' in front of it.Error

Accepted Answer

Adam Danz
Adam Danz on 16 Dec 2021
Edited: Adam Danz on 16 Dec 2021
According to the error, the variable "strain" only contains 6 columns but you're indexing a 7th column that doesn't exist. Either your column indices are incorrect or the "strain" variable is not the expected size.

More Answers (0)

Categories

Find more on Stress and Strain in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!