How can i resloved this problem ?
이전 댓글 표시
I am trying to ged weather from web sie... and i have this issue, when i run the cicle: Index exceeds matrix dimensions.
I use this code :
close all
clear all
%%download weather forecast data from server
current_files=urlread('https://freemeteo.bg/weather/sofia/daily-forecast/today/?gid=727011&language=bulgarian&country=bulgaria');
relev_files=strfind(current_files,'FPTO51.0_r1101_TA.csv');
%for most recent file use last index in relev_files
ta_url=['https://freemeteo.bg/weather/sofia/daily-forecast/today/', ...
'?gid=727011&language=bulgarian&country=bulgaria', ...
current_files(relev_files(1:end)-21:relev_files(1:end)+20)];
% ta_url=['http://dd.weatheroffice.ec.gc.ca/meteocode/ont/csv/',current_files(relev_files(1:end)-21:relev_files(1:end)+20)];
ta_data=urlread(ta_url);
%%put forecast data into vectors
clc
C = [strsplit(ta_data, ('\n'))]' ;
D = char(C(2:end-1));
for I = 1:length(D)
E = strsplit(D(I,:), '-');
year(I) = str2double(char(E(1,1)));
month(I) = str2double(char(E(1,2)));
F = char(E(1,3));
G = strsplit(F, 'T');
day(I) = str2double(char(G(1,1)));
H = char(G(1,2));
J = strsplit(H, ':');
hour(I) = str2double(char(J(1,1)));
min(I) = str2double(char(J(1,2)));
K = char(J(1,3));
L = strsplit(K, 'Z');
sec(I) = str2double(char(L(1,1)));
M = char(L(1,2));
N = strsplit(M, ',');
value(I) = str2double(char(N(1,2)));
end
F = strsplit(D(1,:), 'T')
data=[year' month' day' hour' min' sec' value'];
figure
t = datetime(year, month, day, hour, min, sec, value);
plot(t, value, '*')
hold on
plot(t, value, '-k', 'Linewidth', 2)
axis tight, grid minor
xlabel('Time')
ylabel('Temperature (°C)')
댓글 수: 3
Jan
2019년 5월 2일
Please post the complete error message, such that the readers do not have to guess in which line the problem occurs.
Tsvetan Terziev
2019년 5월 2일
John D'Errico
2019년 5월 2일
Actually, NO. That is not the complete text of the error message. There will be more text, all in red.
채택된 답변
추가 답변 (1개)
Tsvetan Terziev
2019년 5월 5일
카테고리
도움말 센터 및 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!
