How can I loop this ?
Mostrar comentarios más antiguos
I want to change the stations for each different parameter in the loop, any help?
INPUT.IN={... %1-file Type | %2-file | 3-Location (Sea) | 4-Location (hunte) | 5-Location (weser) | 6-Location (Wuemme) | 7-Variable | 8-abv. | 9-abv | 10-Unit | 11-Kennnummer | 12-Prestr | 13-Poststr | 14-VariableLimits | 15-LoadTempData ? y=1
'.dat', '/net/themis/geo/messungen/jadeweser/loc/wasserstand', 'ALW', '', '', '', 'wasserstand', 'wl.', 'wl', 'm NHN', 3, '', ' ', [-4,4], 0;...
'.dat', '/net/themis/geo/messungen/jadeweser/loc/einleitungs-Volumenstrom', '', 'OWH', 'INT', {'HEX'; 'HELL'; 'GRAS'}, 'einleitungs-Volumenstrom', 'sv.', 'sv', 'm NHN', 1058, '', ' seeseitig', [-4,4], 1;...
'.dat', '/net/themis/geo/messungen/jadeweser/loc/Salzgehalt', 'ALW', '', 'HEM', '', 'Salzgehalt', 'sa.', 'sa', 'g/kg', 5, '', ' (2D) seeseitig', [30,35], 1;...
'.dat', '/net/themis/geo/messungen/jadeweser/loc/temperatur', 'ALW', '', 'INT', '', 'temperatur', 'te.', 'te', '°C', 6, '', ' (2D) seeseitig', [0,30], 1 ;...
'.dat', '/net/themis/geo/messungen/jadeweser/loc/truebung', 'DWG', '', 'INT', '', 'truebung', 'tu.', 'tu', 'm', 1161, '', '', [0,5], 0; ... '
};
for f=1:size(INPUT.IN,1)
parameters = INPUT.IN{f,7};
parameters_abv_1 = INPUT.IN{f,8};
parameters_abv_2 = INPUT.IN{f,9};
stations_sea = INPUT.IN{f,3};
stations_hunte = INPUT.IN{f,4};
stations_weser =INPUT.IN{f,5};
stations_wuemme =INPUT.IN{f,6};
kennnummers = INPUT.IN{f,11};
PATH_para = INPUT.IN{f,2};
[~, ~, start_end] = boe_info([PATH_para, '/', num2str(HYD_YEAR-1), '/boewrt/'], 'inputfile', [parameters_abv_1, stations_sea, '.000.', num2str(HYD_YEAR-1), '.boewrt.dat']);
[temp_stats, temp_year, start_end2] = boe_info([PATH_para, '/', num2str(HYD_YEAR), '/boewrt/'], 'inputfile', [parameters_abv_1, stations_sea, '.000.', num2str(HYD_YEAR), '.boewrt.dat']);
start_end = [start_end; start_end2];
[DATA, TIMES] = Year2Hydrolog(PATH_para, stations_sea, start_end, HYD_YEAR, kennnummers, parameters_abv_2);
Respuesta aceptada
Más respuestas (1)
Hassaan
el 28 de Dic. de 2023
To accommodate this in your loop, you can set up a selection mechanism that chooses the non-empty station for each parameter. Here's how you can modify your loop. A initial idea of how you can implement it:
INPUT.IN={... %1-file Type | %2-file | 3-Location (Sea) | 4-Location (hunte) | 5-Location (weser) | 6-Location (Wuemme) | 7-Variable | 8-abv. | 9-abv | 10-Unit | 11-Kennnummer | 12-Prestr | 13-Poststr | 14-VariableLimits | 15-LoadTempData ? y=1
'.dat', '/net/themis/geo/messungen/jadeweser/loc/wasserstand', 'ALW', '', '', '', 'wasserstand', 'wl.', 'wl', 'm NHN', 3, '', ' ', [-4,4], 0;...
'.dat', '/net/themis/geo/messungen/jadeweser/loc/einleitungs-Volumenstrom', '', 'OWH', 'INT', {'HEX'; 'HELL'; 'GRAS'}, 'einleitungs-Volumenstrom', 'sv.', 'sv', 'm NHN', 1058, '', ' seeseitig', [-4,4], 1;...
'.dat', '/net/themis/geo/messungen/jadeweser/loc/Salzgehalt', 'ALW', '', 'HEM', '', 'Salzgehalt', 'sa.', 'sa', 'g/kg', 5, '', ' (2D) seeseitig', [30,35], 1;...
'.dat', '/net/themis/geo/messungen/jadeweser/loc/temperatur', 'ALW', '', 'INT', '', 'temperatur', 'te.', 'te', '°C', 6, '', ' (2D) seeseitig', [0,30], 1 ;...
'.dat', '/net/themis/geo/messungen/jadeweser/loc/truebung', 'DWG', '', 'INT', '', 'truebung', 'tu.', 'tu', 'm', 1161, '', '', [0,5], 0; ... '
};
HYD_YEAR = 2023; % replace 2023 with the actual year you are analyzing
for f = 1:size(INPUT.IN,1)
parameters = INPUT.IN{f,7};
parameters_abv_1 = INPUT.IN{f,8};
parameters_abv_2 = INPUT.IN{f,9};
% Initialize station as empty
station = '';
% Determine the non-empty station for the current parameter
if ~isempty(INPUT.IN{f,3})
station = INPUT.IN{f,3};
elseif ~isempty(INPUT.IN{f,4})
station = INPUT.IN{f,4};
elseif ~isempty(INPUT.IN{f,5})
station = INPUT.IN{f,5};
elseif ~isempty(INPUT.IN{f,6})
station = INPUT.IN{f,6};
end
% If no station is found, continue to the next iteration
if isempty(station)
warning('No station found for parameter %s', parameters);
continue;
end
kennnummers = INPUT.IN{f,11};
PATH_para = INPUT.IN{f,2};
% Assuming 'HYD_YEAR' and 'boe_info' is defined previously in your script
[~, ~, start_end] = boe_info([PATH_para, '/', num2str(HYD_YEAR-1), '/boewrt/'], 'inputfile', [parameters_abv_1, station, '.000.', num2str(HYD_YEAR-1), '.boewrt.dat']);
[temp_stats, temp_year, start_end2] = boe_info([PATH_para, '/', num2str(HYD_YEAR), '/boewrt/'], 'inputfile', [parameters_abv_1, station, '.000.', num2str(HYD_YEAR), '.boewrt.dat']);
start_end = [start_end; start_end2];
[DATA, TIMES] = Year2Hydrolog(PATH_para, station, start_end, HYD_YEAR, kennnummers, parameters_abv_2);
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
1 comentario
janas
el 28 de Dic. de 2023
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!