Someone can explain to me how to generate and save a txt, excel file data, after "for loop" and is meshgrid ?
Mostrar comentarios más antiguos
Hi,
I have the following script to run the attached data.
fname1 = uigetfile({'*.txt;*.dat;*.tab','Data Files (*.txt,*.dat,*.tab)'; '*.*','All Files (*.*)'},'Ficheiro de dados da Pangaea');
[name,latitude,longitude,depth,agemodel] = textread(fname1,'%s %f %f %f %f','headerlines',1);
agemodel2 = abs(agemodel-20)
LLDA = [latitude,longitude,depth,agemodel,agemodel2]; % Matriz
LLDAn = LLDA(:,1:5); %LLDA(:,2:5)
LLDAm = LLDAn;% cell2mat(LLDAn)
[LatUq, iL, iU] = unique(LLDAm(:,1));
[LonUq, iL, iU] = unique(LLDAm(:,2));
idade_int = zeros(numel(LatUq),numel(LonUq)) * NaN;
for n=1:numel(LonUq)
for m = 1:numel(LatUq)
ind = find(LLDAm(:,2) == LonUq(n) & LLDAm(:,1) == LatUq(m));
if (isempty(ind)), continue; end
%idade_int(n,m) = interp1([0; agemodel(ind)],[0; depth(ind)],20,'linear','extrap');
p = polyfit([0; agemodel(ind)],[0; depth(ind)], 1);
idade_int(m,n) = polyval(p, 20);
end
end
[lon,lat] = meshgrid(LonUq,LatUq)
Is that my results are the following: (for exemple)
lon1 lon2 lon3
lat1 NAN 1 NAN
lat2 NAN NAN 2
lat3 2 NAN NAN
Someone explain to me how to generate and save a txt, excel file data in the following way:
LongUq, LatUq, idade_int
??
Thank you very much Nuno Simões
3 comentarios
Jan
el 22 de Abr. de 2014
You you define the wanted output more precisely? "The following way: LongUq, LatUq, idade_int" is not clear enough for an efficient answer.
Nuno Simões
el 23 de Abr. de 2014
Nuno Simões
el 23 de Abr. de 2014
Respuestas (1)
Lee Albacker
el 22 de Abr. de 2014
0 votos
Assuming you want to concatenate the arrays (I'll also assume you can add your own headers if you want):
output = [LongUq, LatUq, idade_int];
To write to an xcell file: xlswrite('FILENAME.xlsx', output); file ends up in your current matlab path
To write to a text file that's tab delimited: dlmwrite('FILENAME.txt', output, 'delimiter', '\t', 'precision', NUMBER OF DECIMAL PLACES)
1 comentario
Nuno Simões
el 23 de Abr. de 2014
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!