creating a matrix from different sized arrays
2 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Andrei Bobrov
on 15 May 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);
0 Comments
More Answers (1)
Sean de Wolski
on 15 May 2012
This should get you started, ask us for any clarifications.
0 Comments
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!