matlab 解方程,绘图,程序如下:S1=solve('sin(x)-a*cos(x)=0.8',

发布时间:2021-02-26 10:03:55

matlab 解方程,绘图,程序如下:S1=solve('sin(x)-a*cos(x)=0.8','x');a=0.1:0.1:1;s01=eval(s1);y=tan(s01);plot(a,y)程序功能可以实现,就是出现一个warning,提示错误使用 plot 因为y里面有 ‘复数’,怎么解决这个问题,新手没多少分,多多包涵!我用的是matlab 2010b 版本,用plot画图,wari

网友回答

By checking your s01:
>> s01s01 = Columns 1 through 5
1.0204 1.0992 1.1645 1.2177 + 0.0000i 1.2610 + 0.0000i
2.3206 2.4372 2.5600 + 0.0000i 2.6849 2.8078
Columns 6 through 10
1.2964 + 0.0000i 1.3254 + 0.0000i 1.3495 1.3696 + 0.0000i 1.3867
2.9260 3.0376 + 0.0000i -3.1416 - 0.0000i -3.0456 + 0.0000i -2.9575
You will notice that all image parts are zeros. So you can simply get rid of them:
>> s01 = real(s01)
s01 = 1.0204 1.0992 1.1645 1.2177 1.2610 1.2964 1.3254 1.3495 1.3696 1.3867
2.3206 2.4372 2.5600 2.6849 2.8078 2.9260 3.0376 -3.1416 -3.0456 -2.9575
======以下答案可供参考======
供参考答案1:
我运行了一下,没错,注意一点matlab分大小写
供参考答案2:
对于复函数画图显示,我们一般都是将其实部或者虚部分别显示的,要么就显示其幅值等等。
以上问题属网友观点,不代表本站立场,仅供参考!