Index exceeds matrix dimensions
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am having an issue with the index exceeds matrix dimensions which for the life of me I can't understand because this is very similar (almost identical) to a piece of code I have previously written for the same assignment task which worked perfectly only the data has been scaled up to be metres as opposed to millimetres.
The data for the dam depths is a 36 x 20 array
a = xlsread('C:\Users\Rhys\Desktop\Matlab assignment\Task 2\dam_data.xlsx')*-1; %load data and correct orrientation
[X,Y] = meshgrid(1600:200:5400,2400:200:9400); %grid for measurement incrememnts (scaled 1:10000 and converted to m)
H_max = min(min(a)); %deepest point in dam
h_current = 16.2; %current dam water level
b = a<0; %determine points below dam wall height
c = a.*b; %correcting data to show points only below dam wall height
e = 0;
for i = 1 : X - 1 %determine to scale capacity
e = e + (-c(i+1) + -c(i))/4 * (X(i+1)-X(i));
for j = 1 : Y - 1
e = e + (-c(j+1) + -c(j))/4 * (Y(j+1)-Y(j));
end
end
the offending line of code is which continues in a loop until it gets to 720 iterations then stops is
for j = 1 : Y - 1
e = e + (-c(j+1) + -c(j))/4 * (Y(j+1)-Y(j));
end
The error message I get is
Index exceeds matrix dimensions.
Error in assignment_code (line 19) e = e + (-c(j+1) + -c(j))/4 * (Y(j+1)-Y(j));
Any help with this would be appreciated as for the most part what I have learnt has been through google and I am really struggling with this one (I managed to fix by pure fluke last time I had this issue).
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!