0

I am a beginner of Matlab. I am trying to run this function but there seem to be a syntax error that I cannot understand. The source code is the following.

function print_trace(x)
for rowi=1:size(x,1),
    for coli=1:size(x,2),
        disp(x(rowi,coli))
    end
end

The error encountered is the following:

??? Input argument "x" is undefined.

Error in ==> print_trace at 2
for rowi=1:size(x,1),

Any ideas?

EDIT: here is a screenshot: http://imgur.com/pwPhzhh

EDIT 2:

Trying to see if there are multiple copies running:

>> which('print_trace')
C:\Users\stablum\Dropbox\cm\print_trace.m

EDIT: solution of the problem :)

it seems that I solved the problem, my mistake was running ("play" button) the file of the function instead of just calling the function (which will load the file automatically). I still don't understand why there was this error when the file is run, but at least my problem is solved.

4

1 回答 1

0

我想这是因为你调用函数的方式。

该错误表明您没有提供所需的参数x。特别是,你似乎用

print_trace()

或者

print_trace

或者

print_trace(empty_cell{:})

这导致没有值可以分配给x

于 2013-06-29T19:44:53.327 回答