Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
也许这是一个非常简单的问题,但是我已经在互联网上寻找答案了几个小时,但找不到。
我已经创建了下面的函数。在另一个m文件中,我想使用矩阵“ actual_location”。但是,不可能使用矩阵的单个单元格(即actual_location(3,45)或actual_location(1,2))。当我尝试使用单个单元格时,出现以下错误: ??? Error using ==> Actual_Location Too many input arguments. 谁能告诉我我必须更改什么,以便我可以读取矩阵的各个单元格? function [actual_location] = Actual_Location(~); actual_location=zeros(11,161); for b=1:11 for t=1:161 actual_location(b,t) = (59/50)*(t-2-(b-1)*12)+1; if actual_location(b,t) < 1 actual_location(b,t) =1; end end actual_location(1,1) end 回答: 定义好后,由函数Actual_Location编写的矩阵在m文件中的名称为Actual_location。但是,当您调用函数时,可以给输出任何您喜欢的名称。我想您是这样称呼的,记住Matlab区分大小写: actual_location = Actual_Location(arguments); 您只是为了混淆自己而写作。对于函数定义中的哑元参数,使用不同于Actual_location的名称,然后调用函数以返回具有更独特名称的变量,如下所示: output = Actual_Location(arguments); 似乎您可能期望Actual_location(1,1)返回数组的元素1,1,而它可能是带有2个输入参数的函数调用。 更多&回答... |
![]() |
![]() |