2012-10-15 3 views
2

Я хочу использовать корни функции 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]); 

ответ

4

Я думаю, что MATLAB говорит вам все, что вам нужно знать, на самом деле. Вы определили переменную, называемую «корнями», как возвращаемое значение из вашей функции, но «корни» - это уже функция, поэтому вам не разрешено использовать одно и то же имя. Попробуйте следующее:

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 
+0

О, мой бог !!! Я, конечно, слепой. Спасибо за быстрый ответ –

Смежные вопросы