Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to overcome array problem?

1 vue (au cours des 30 derniers jours)
hanif hamden
hanif hamden le 19 Jan 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaires
darova
darova le 19 Jan 2020
Can you please explain more: what are you trying to do and what is the problem?
Stephen23
Stephen23 le 19 Jan 2020

Réponses (0)

Cette question est clôturée.

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by