开发者

Matlab - running an (x,y) function on respective columns of 2 matrices

开发者_如何学编程

I have a quick Matlab question. In the code below, I am dividing two arrays(Upper and Lower) into subsets by dumping 36(binSize) into each column of subsetArrayU/L.

Here's what I want to do: i want to run a function I defiined earlier on subsetArrayL and subsetArrayU comparing column 1 of each to each other. (ie. sub1= fitellipse(subsetArrayL(:,1), subsetArrayu(:,1));)

I need to find a way to automated the process of matching each of the 54(nBins) columns up and running them through fitellipse. I would really appreciate some help, just let me know if you need any more info!

binSize = 36;
nData = length(Upper);
nBins = floor(nData/binSize);
nDiscarded = nData - binSize*nBins;

subsetArrayU=reshape(Upper(1:binSize*nBins),[],nBins); 
subsetArrayL=reshape(Lower(1:binSize*nBins),[],nBins);

fitsub1= fitellipse(subsetArrayL(:,1),subsetArrayU(:,1));


Wouldn't simple looping be enough, like

fitsubs= zeros(nBins, 5) %# assuming fitellipse returns a row vector
for j= 1: nBins
    fitsubs(j, :)= fitellipse(subsetArrayL(:, j), subsetArrayU(:, j));
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜