Index exceeds matrix dimensions Error.
이전 댓글 표시
Hi!
I'm working on a script and while it works with smaller vectors, I can't get it to work with the one I need it to work with which is considerably larger.
Index exceeds matrix dimensions.
Error in avalanchePredictor (line 31)
dist(i) = sqrt((weather(i,4) - current(1))^2 + (weather(i,5) -
current(2))^2 + (weather(i,6) - current(3))^2 + (weather(i,7) -
current(4))^2);
This is the exact error message that I'm getting and below is the code line 31 is around for reference.
dist = zeros(1, 100000);
weather = importdata('weather.csv');
for i = 1:11434
dist(i) = sqrt((weather(i,4) - current(1))^2 + (weather(i,5) - current(2))^2 + (weather(i,6) - current(3))^2 + (weather(i,7) - current(4))^2);
end
for i = 1:11434
fprintf(fid,'%10.0f %10.0f %10.0f %10.3f \n', weather(i,(1:3)), dist(i));
end
fid = fclose('all');
As I said, I think I'm trying to loop it for too long or something (I'm not very good at MATLAB to begin with...), and I tried following some fo the suggested steps, but to no avail. Can anybody help me out?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!