Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
How do I apply a function 360 times to a number of rows of data using a loop (or other method)?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have an excel sheet with columns of (1) latitude, (2) longitude, (3) range (m), (4) depth (m) and (5) transect number (1:360). Each transect has 1016 rows. I wish to apply a function (weston_function below) to all rows of each transect (starting with 1 and finishing with 360). It would be useful for the function to also output the transect number for each row as well as the values for R, H, Transmission Loss (TL) at each row.
Currently I have this as my code but I am aware this does not work...
if true
% Input xlsx file for data
data = xlsread('Outputs_360Transects_20180627.xlsx',1);
% Input data required by function
R = data(:, 3); % Range (m)
H = data(:,4); % Depth (m)
T = 15.; % Temperature
S = 37.; % Salinity
c_sed = 1800;
rho_sed = 2.0;
attn = 0.6;
freq_Hz = 10000.;
% Run function 360 times
n = 1:360;
for i = 1:n
[R,H,TL, Transect] = weston_function(R, H, T, S, c_sed, rho_sed, attn, freq_Hz);
end
3 comentarios
Guillaume
el 27 de Jun. de 2018
How does the weston_function know what Transect number to return? Is that function actually written yet? If it is already written can you show its code?
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!