필터 지우기
필터 지우기

Parentheses error with a function call

조회 수: 5 (최근 30일)
Jaya
Jaya 2021년 5월 10일
댓글: Walter Roberson 2021년 5월 11일
What is wrong with this function call? It's so basic but don't know what I am missing.
The error is "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters."
load('mnist.mat', 'testX');
% save('testX'); commented it based on the reply I got for this question
x=testX; % testX is a 529*784 matrix
k=5; numIter=6;
[mu, cll, ill] = gmm(x, k,numIter)
% the function definition starts like this in another file
% function [mu,CLL,ILL] = gmm(x,K,numIter)
  댓글 수: 4
Jaya
Jaya 2021년 5월 10일
편집: Jaya 2021년 5월 10일
Oh, it's working now!!!!
Turns out this posted code excerpt was perfectly okay. Inside the function definition, there was one ) missing for one line.
Thanks for the save() suggestion.
Walter Roberson
Walter Roberson 2021년 5월 10일
I do not see any problem with the code extract that you posted.
Perhaps the error is inside gmm function .

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

채택된 답변

VBBV
VBBV 2021년 5월 11일
%if true
x = load('mnist.mat', 'testX');
k=5;
numIter=6;
function [mu, cll, ill] = gmm(x, k,numIter)
Assign x directly when loading
  댓글 수: 4
Jaya
Jaya 2021년 5월 11일
편집: Jaya 2021년 5월 11일
Thanks again for the reply. What I meant in my previous answer was I did in the way you proposed in the beginning. I didn't know that VBBV's answer and your answer would give different result into x and that's why i commented like that thinking they give same x.
I didn't see any button for accepting your answer..
Walter Roberson
Walter Roberson 2021년 5월 11일
Assigning the output of load() is a good idea... it just isn't the reason you had the problem in this situation, and the change was not coded for correctly in VBBV's answer.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 5월 11일
[copying down from correct comment]
I do not see any problem with the code extract that you posted.
Perhaps the error is inside gmm function .

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by