error: Function definitions are not permitted in this context

1 次查看(过去 30 天)
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