Matlab 拍摄关于x=a的函数的图像
我是编程和MATLAB的初学者。 问题: 我有一个从0到a的函数f(x)。我需要在x=a上反映这一点,这样区域a中的图形Matlab 拍摄关于x=a的函数的图像,matlab,matlab-figure,Matlab,Matlab Figure,我是编程和MATLAB的初学者。 问题: 我有一个从0到a的函数f(x)。我需要在x=a上反映这一点,这样区域a中的图形 x =0:16/100:16; if all(x<8) m = 0.00003 + 0.00002./((cos(pi/4)./sinh(0.5*log(0.5*x)))+coth(0.5*log(0.5*x))); end if all(x>8) p = 0.00003 + 0.00002./((cos(pi/4)./sinh(0.5*log(0
x =0:16/100:16;
if all(x<8)
m = 0.00003 + 0.00002./((cos(pi/4)./sinh(0.5*log(0.5*x)))+coth(0.5*log(0.5*x)));
end
if all(x>8)
p = 0.00003 + 0.00002./((cos(pi/4)./sinh(0.5*log(0.5*(16-x))))+coth(0.5*log(0.5*(16-x))));
end
z = m + p ;
plot(x,z);grid on
x=0:16/100:16;
如果全部(x8)
p=0.00003+0.00002./(cos(pi/4)。/sinh(0.5*log(0.5*16-x))+coth(0.5*log(0.5*16-x));
结束
z=m+p;
图(x,z);网格化
但是,这里x是一个数组。
我该如何处理这个问题?
我是新手,请指出我的错误。我很乐意作进一步澄清。提前感谢您的帮助。让我们假设
f
是一个数组,包含与参数x
相对应的从0到a
的函数值。然后,您可以执行以下操作:
f1=[f f(end:-1:1)];
x=[x x(end)+x+x(1)];
plot(x,f1)
矢量化
z = ( x <= 8 ) .* ... % select the first part
( 0.00003 + 0.00002./((cos(pi/4)./sinh(0.5*log(0.5*x)))+coth(0.5*log(0.5*x))) ) + ...
( x > 8 ) .* ... % select second part
( 0.00003 + 0.00002./((cos(pi/4)./sinh(0.5*log(0.5*(16-x))))+coth(0.5*log(0.5*(16-x)))) ) ;
plot( x, z );
z=(x8)。*…%选择第二部分
(0.00003+0.00002./(cos(pi/4)。/sinh(0.5*log(0.5*16-x))+coth(0.5*log(0.5*16-x));
图(x,z);