根在函数中不起作用 [英] roots doesn't work in a function
本文介绍了根在函数中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在函数中使用matlab函数的根.
I want to use the matlab function roots in a function.
但是它不起作用.我不知道如何解决这个问题.
But it doesn't work. I have no idea how to solve that problem.
这是函数:
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]);
推荐答案
我认为matlab实际上会告诉您您需要了解的所有内容.您已经定义了一个名为"roots"的变量作为函数的返回值,但是"roots" 已经是一个函数,因此不允许使用相同的名称.试试这个:
I think matlab is telling you everything you need to know, actually. You have defined a variable called "roots" as the return value from your function, but "roots" is already a function, so you are not allowed to use the same name. Try this:
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
这篇关于根在函数中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文