Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 如何访问单元格数组中的函数句柄?_Matlab_Cell Array_Function Handle - Fatal编程技术网

Matlab 如何访问单元格数组中的函数句柄?

Matlab 如何访问单元格数组中的函数句柄?,matlab,cell-array,function-handle,Matlab,Cell Array,Function Handle,我以这种方式定义了一个单元格数组,并尝试以以下方式进行访问: rate_arr_cst_1 = @(t) 2*sin(t)+10; rate_arr_cst_2 = @(t) 3*sin(2*t)+8; rate_arr_cst_h = {rate_arr_cst_1, rate_arr_cst_2}; 但我在这里得到的仍然是一个单元格数组,这意味着我不能用h来计算t=0.1 非常感谢你的帮助 当你做h=rate\u arr\u cst\u h(i),您正在访问单元格数组的第i个元素,该元素

我以这种方式定义了一个单元格数组,并尝试以以下方式进行访问:

rate_arr_cst_1 = @(t) 2*sin(t)+10; 
rate_arr_cst_2 = @(t) 3*sin(2*t)+8;
rate_arr_cst_h = {rate_arr_cst_1, rate_arr_cst_2};
但我在这里得到的仍然是一个单元格数组,这意味着我不能用h来计算t=0.1


非常感谢你的帮助

当你做
h=rate\u arr\u cst\u h(i)
,您正在访问单元格数组的第i个元素,该元素仍然是单元格。如果要访问单元格数组中
i^th
单元格的内容,需要执行以下操作:
h=rate\u arr\u cst\u h{i}。注意使用花括号。

使用for循环:

i=1;
h = rate_arr_cst_h(i);
或者您可以使用
cellfun

for ii = 1:numel(rate_arr_cst_h)
    hh(ii) = rate_arr_cst_h{ii}(i);
end

如果任何答案解决了您的问题,请点击答案旁边的勾号接受。如果没有,请发表评论,以便人们知道您需要在特定问题上的进一步帮助。
hh = cellfun(@(f) f(i), rate_arr_cst_h);