フィルターのクリア

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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by