필터 지우기
필터 지우기

error: Function definitions are not permitted in this context

조회 수: 1 (최근 30일)
Amine Ben Ayara
Amine Ben Ayara 2015년 8월 18일
댓글: Amine Ben Ayara 2015년 8월 18일
Hello, I have been trying to run a code that uses for loops, and I keep getting the error message: Function definitions are not permitted in this context, at the end. Here is my original 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)=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) = exp(Y(i+1,l)* dot(X(i,:),Lam(j,:)))/Den(i,l);
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;
Can someone help please.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 8월 18일
ProbabiltyMatrices is a function, you can't run it by clicking run. To use this function, assign values to
X=
Lam=
Y=
Then call your function
MN = ProbabiltyMatrices(X,Lam,Y)
  댓글 수: 1
Amine Ben Ayara
Amine Ben Ayara 2015년 8월 18일
Hey Azzi, Thank you so much for replying so quick. In fact, I have three variables which are already created and contain data that I used for this code. X, Lam & Y are the three matrices that I used.

댓글을 달려면 로그인하십시오.

카테고리

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