Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Transform algorithm avoiding loops

1 回表示 (過去 30 日間)
MRC
MRC 2014 年 5 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi, I have to transform the following algorithm in an algorithm without loops.
Consider a matrix A with the following characteristics:
A=[[1 2; 1 3; 1 4; 2 1; 2 6; 3 1; 3 2; 3 3; 3 4; 3 5] randi([0,1], 10,2)];
In particular, the characteristics of A which I can rely on are: the first column shows all increasing numbers from 1 to n=3, but we don't know how many times each number is repeated; for each number from 1 to n=3, some numbers between 1 and m=6 are associated in the second column, not necessarily in an increasing order.
I construct a vector Y of dimension (size(A,1))x1 in the following way:
n=max(A(:,1));
m=max(A(:,2));
gamma=2;
delta=-3;
Y=zeros(size(A,1),2);
for t=1:m
At=A(A(:,2)==t,:);
for l=1:size(At,1)
Yl= mvnrnd((gamma/delta*At(l,3:end))',eye(n-1)); %1x(n-1)
ismember(A(:,1:2),[At(l,1) t],'rows');
Y(index,:)=Yl
end
end
I want to rewrite the algorithm above without loops. Could you help me?

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by