我想在函数中使用matlab函数根。
但它不起作用。我不知道如何解决这个问题。
这是功能:
function [ roots , poles ] = pr_calc( num , den )
%PR_CALC Summary of this function goes here
% Detailed explanation goes here
poles=roots([den]);
roots=roots([num]);
end
这是错误消息:
??? At compilation, "roots" was determined to be
a variable and this
variable is uninitialized. "roots" is also a
function name and previous versions of MATLAB
would have called the function.
However, MATLAB 7 forbids the use of the same
name in the same
context as both a function and a variable.
Error in ==> pr_calc at 6
poles=roots([den]);
答案 0 :(得分:4)
我认为matlab实际上告诉了你需要知道的一切。您已将名为“roots”的变量定义为函数的返回值,但“roots” 已经是函数,因此不允许使用相同的名称。试试这个:
function [ myroots , poles ] = pr_calc( num , den )
%PR_CALC Summary of this function goes here
% Detailed explanation goes here
poles=roots([den]);
myroots=roots([num]);
end