how can I solve Undefined operator '^' for input arguments of type 'function_handle'. problem?

h=0.1;
a=5.02;
b=9.13;
c=35.7;
t=0:h:100;
l=length(t);
v=@(t) (a*t ^(a-1))/(c ^a)*cosh(b*t/100)+((t/c) ^a)*(b/100)*sinh(b*t/100);
y=@(t) ((t/c) ^a)*cosh(b*h/100)
alt=zeros(1,l);
accd=zeros(1,l);
accel=zeros(1,l);
ateor=zeros(1,l);
a=@(t) 3.24006e-7*x ^(3.02)
for i=1:l
accd=(-3*v(t(i))+4*v(t(i)+h)-v(t(i)+2*h))/(2*h);
end
for i=1:l
alt(i)=((t(i)/c) ^a)*cosh(b*h/100);
accel(i)=(y(t(i)+h)-2*y(t(i))+y(t(i)-h))/(h ^2)
ateor(i)=a(t(i));
end
plot(t,accd)
hold on
plot(t,accel,'r')
plot(t,ateor,'g')
legend('accd','accel','ateor')
xlabel('Time')
ylabel('Acceleration')

 采纳的回答

alt(i)=((t(i)/c) ^a(t(i)))*cosh(b*h/100);
Notice you had to invoke a at t(i) -- which you did do properly two lines further below.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by