Effacer les filtres
Effacer les filtres

error: Function definitions are not permitted in this context

1 vue (au cours des 30 derniers jours)
Amine Ben Ayara
Amine Ben Ayara le 18 Août 2015
Commenté : Amine Ben Ayara le 18 Août 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.

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 18 Août 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 commentaire
Amine Ben Ayara
Amine Ben Ayara le 18 Août 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by