Someone can explain to me how to generate and save a txt, excel file data, after "for loop" and is meshgrid ?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Lee Albacker
il 22 Apr 2014
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)
Vedere anche
Categorie
Scopri di più su Data Import and Export in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!