Filter löschen
Filter löschen

error: Function definitions are not permitted in this context

1 Ansicht (letzte 30 Tage)
Amine Ben Ayara
Amine Ben Ayara am 18 Aug. 2015
Kommentiert: Amine Ben Ayara am 18 Aug. 2015
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.

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 18 Aug. 2015
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 Kommentar
Amine Ben Ayara
Amine Ben Ayara am 18 Aug. 2015
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by