Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to overcome array problem?

1 visualizzazione (ultimi 30 giorni)
hanif hamden
hanif hamden il 19 Gen 2020
Chiuso: MATLAB Answer Bot il 20 Ago 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 Commenti
darova
darova il 19 Gen 2020
Can you please explain more: what are you trying to do and what is the problem?

Risposte (0)

Questa domanda è chiusa.

Prodotti


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by