필터 지우기
필터 지우기

creating a matrix from different sized arrays

조회 수: 1 (최근 30일)
Michael
Michael 2012년 5월 15일
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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 5월 15일
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);

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2012년 5월 15일
This should get you started, ask us for any clarifications.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by