how do i export indiviudal cells of an array into seperate csv files with horizontal merging ?

2 vues (au cours des 30 derniers jours)
numfiles = 20;
mydata = cell(1, numfiles);
m=1;
for k = 1:numfiles
myfilename = sprintf('sample%d.txt', k);
mydata{k} = importdata(myfilename);
x{k} = mydata{k}(:,1);
x{k} = x{k}/1000;
y{k} = mydata{k}(:,2);
for i = 1:length(mydata{k})
if (y{k}(i) >= 250 )
c(m,1)=x{k}(i);
c(m,2)=y{k}(i);
else
c(m,1)=x{k}(i);
c(m,2)=0;
end
m = m+1;
end
output{k}=c;
w{k} = output{k}(:,1);
q{k} = output{k}(:,2);
[f{k},X_f{k}]=fourier(w{k},q{k},'sinus');
o{k}=100*(abs(mean(X_f{k}(:),'all')));
e{k} = {w{k},q{k},f{k},X_f{k},o{k}};
writecell(e{k},'tremorsdatabase%d.csv',k);%% this doesnt work
m=1;
end
Error using importdata
Unable to open file.
So here I am trying to export my values into a single array E,
E will contain five values per cell
for example e{1} = { time(20000x1) , amplitude(20000 x 1 ), frequency(1 x 10000) , fourier complex frequency(1 x 10000) , mean frequency(1x1)
}
i need every exported csv file to contain one e{1}
is there anyway i can do it ?
  1 commentaire
manav chawla
manav chawla le 30 Juin 2022
my total size of e = 40, hence e{1} = 1x 5 array with all the values mentioned. e{all} = 40 (1 x 5) arrays with sub arrays of 5 values each.
value 1 size = 20000 x 1
value 2 size = 20000 x 1
value 3 = 1 x 10000
value 4 = 1 x 10000
value 5 = 1 x 1
i want for example e{1} to be stored in one csv file, e{2} in another csv file within the loop

Connectez-vous pour commenter.

Réponses (1)

Pratyush Swain
Pratyush Swain le 3 Sep 2023
Hey manav,
I understand you want to export individual cell values of a cell array. Please verify the values passed into the cell array.Another workaround could be testing on some dummy data before using the actual file data.
For further reference you can refer to saving cell array to file.
Hope this helps.

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by