为什么我不能使用开机功能?

ido*_*198 3 matlab exponent

我写了这段代码:

t=linspace(0,pi)
x = @(t)sin(t)
Run Code Online (Sandbox Code Playgroud)

然后我尝试了这个->

x = power(x,2)
Run Code Online (Sandbox Code Playgroud)

但是它给我一个错误,那我该如何在一个函数上使用幂函数?

And*_*uri 6

你不能

但是,您可以在函数的输出上使用幂函数

x = @(t)sin(t); %this is an anonymous function

t=linspace(0,pi); % this is an array

x2 = power(x(t),2); % this is an array
Run Code Online (Sandbox Code Playgroud)

或者,您可以创建第二个函数来调用第一个函数

x2=@(t)power(x(t),2); % this is  an anonymous function
Run Code Online (Sandbox Code Playgroud)