Info
此问题已关闭。 请重新打开它进行编辑或回答。
How do I apply a function 360 times to a number of rows of data using a loop (or other method)?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Guillaume
2018-6-27
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?
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!