필터 지우기
필터 지우기

For loop code/ help

조회 수: 1 (최근 30일)
Amine Ben Ayara
Amine Ben Ayara 2015년 8월 19일
답변: Walter Roberson 2015년 8월 19일
Hello Matlab wizards, So I just finished my 10th attempt at writing a code using for loops. The output was correct. MY issue is that I'm not being successful at adding one more loop that will allow matlab to rerun the same simulation 10 times, so I can get 90 matrices (3*3 each) and 10 matrices (9*3) in the end results. here is my code:
function [ MN ] = ProbabiltyMatrices( X,Lam,Y)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
for i=1:9
for l=1:3
for j=1:3
Den(i,l,n)=exp (Y(i+1,l)* dot(X(i,:),Lam(1,:))) + exp(Y(i+1,l)* dot(X(i,:),Lam(2,:))) +exp(Y(i+1,l)* dot(X(i,:),Lam(3,:)));
MN(l,j,i,n) = exp(Y(i+1,l)* dot(X(i,:),Lam(j,:)))/Den(i,l,n);
end
end
end
Ml =transpose(transpose(MN(:,:,1))* transpose(Y(2,:)));
for i=2:9
Ml(i,:)=transpose(transpose(MN(:,:,i))* transpose(Ml(i-1,:)));
end
M=Ml;
Would someone please help! Thanks

답변 (1개)

Walter Roberson
Walter Roberson 2015년 8월 19일

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by