Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to overcome array problem?

1 次查看(过去 30 天)
hanif hamden
hanif hamden 2020-1-19
关闭: MATLAB Answer Bot 2021-8-20
Hi everyone,
I would to extract each cycle and append it all. Since my coding works manually as I have to keep change the number of j=2, run, j=3, then run again. Could you help me sir if possible? if I put j=2:354, there will be an error at Dist1=d1km. My coding as shown below. Can anyone help me to solve this?
clc;clear all;close all;
% Input matrix
A = dlmread('Ntxp0014.txt');
% Identify and extract each row according to cycle
V = 11:364;
F = @(n) A(A(:,5)==n,:);
C = arrayfun(F,V,'UniformOutput',false);
% Reference LatLon of Cycle 11
ref_latC1 = C{1}(:,2);
ref_lonC1 = C{1}(:,3);
latlon1 = [ref_latC1 ref_lonC1];
% LatLon of Cycle 12 to 364
for j=22 %2-354 <-I have to run one by one
obs_latC2 = C{j}(:,2);
obs_lonC2 = C{j}(:,3);
latlon2 = [obs_latC2 obs_lonC2];
%Extract minimum distance point by point
for k= 1:length(latlon2)
[d1km(k)]=lldistkm(latlon1(1,:),latlon2(k,:));
Dist1 = d1km';
end
B2 = [C{j} Dist1];
ind2=B2(:,7)== min(B2(:,7));
B2 = B2(ind2,:);
%Append the data with ref point
%Append1 = [C{1}(1,:) 0 ; B2] %<-run this for j=2 only
Append1 = [B2] %<-run this for j=3...354
fid = fopen('txp0014_pt1.txt','a');
fprintf(fid,'%17.2f \t %.6f \t %.6f \t %.3f \t %.0f \t %.0f \t %.4f\n',Append1.');
fclose(fid);
end
  4 个评论
darova
darova 2020-1-19
Can you please explain more: what are you trying to do and what is the problem?

回答(0 个)

此问题已关闭。

标签

产品


版本

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by