Azzera filtri
Azzera filtri

creating a matrix from different sized arrays

1 visualizzazione (ultimi 30 giorni)
Hello,
i have some test data to analyse, the data is in arrays of varying size but the names of the arrays are all similar eg; mmXXXgX (where X are numbers relating to a specific test situation)
Basically everything is taking ages to do because i can't seam to make a matrix out of it, i also don't want to cut down any of them as the amount of data varies significantly from one to the next. i was thinking about extending them with 0s but i was worried it would mess up the results if it tried to Fourier transform them.
The latest thing i have been trying involves a matrix of their names as text strings but this doesn't seem to work either.
I have never used this forum before so please let me know if i have missed anything out.
this is the code from the last attempt (it was a bit hopeful i didn't really expect it to work):
a=['mm100g0','mm155g0','mm195g0','mm215g0','mm235g0','mm295g0'
'mm100g1','mm155g1','mm195g1','mm215g1','mm235g1','mm295g1'];
peakv=zeros(size(a));
for r=1:2
for c=1:6
peakv(r,c)=fd(a(r,c));
end
end
fd() is just a function that returns a single value (the peak voltage)
Any help would be greatly appreciated, thank you
Michael

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 15 Mag 2012
x = [100 155 195 215 235 295];
y = 0:1;
[ii jj] = ndgrid(y,x);
a = eval(['reshape({',sprintf('mm%dg%d,',[jj(:),ii(:)]'),'},size(jj))']);
or:
a={mm100g0,mm155g0,mm195g0,mm215g0,mm235g0,mm295g0;mm100g1,mm155g1,mm195g1,mm215g1,mm235g1,mm295g1}
% example of use
peakv = cellfun(@fd,a);

Più risposte (1)

Sean de Wolski
Sean de Wolski il 15 Mag 2012
This should get you started, ask us for any clarifications.

Categorie

Scopri di più su Matrices and Arrays 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!

Translated by