开发者

Accessing variables from a .m file

I run a program, which is a function - here I'll call it 'myfxn' - that output开发者_运维问答s several different variables. But when I try to access the data I get

??? Undefined function or variable 'myfxn'.

How do I access the data? Thanks for your help.


Your question is a bit confusing - you claim you run the function, but then you also say that Matlab throws an error indicating it can't run the function.

Here's two things to test

  1. Is myfxn on the Matlab path? Run the command which myfxn. If that does not find the function, change directory (using cd or the directory browser on the Matlab Desktop) to where myfxn is located.
  2. Does the function actually generate output? If it's a function, the first line should look something like this: function [out1,out2] = myfxn(in1,in2), where in1 and in2 are two input arguments, and out1 and out2 are output arguments. Then, you could call myfxn like this: [a,b] = myfxn(2,'something');, and it will use the two inputs to generate the two outputs, which are assigned to a, and b, respectively.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜