필터 지우기
필터 지우기

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