主题:matlab中的if用法
h(t)=1-t/Ts 0<t<=Ts;
=1+t/Ts -Ts<t<=0;
=0 其它
我用matlab写的时候
dt=0.001;
t=-2:dt:2;
Ts=1;
if ((t>0) && (t<=Ts))
ht=1-t./Ts;
elseif ((t<=0) &&(t>=-Ts))
ht=1+t./Ts;
else ht=0;
end
plot(t,ht);
运行时就出现错误了
Operands to the || and && operators must be convertible to logical scalar values
这个程序该怎么改啊?
需要把h(t)图形画出来
=1+t/Ts -Ts<t<=0;
=0 其它
我用matlab写的时候
dt=0.001;
t=-2:dt:2;
Ts=1;
if ((t>0) && (t<=Ts))
ht=1-t./Ts;
elseif ((t<=0) &&(t>=-Ts))
ht=1+t./Ts;
else ht=0;
end
plot(t,ht);
运行时就出现错误了
Operands to the || and && operators must be convertible to logical scalar values
这个程序该怎么改啊?
需要把h(t)图形画出来