mathematica作图的错误fp = {{23.604,9.983},{26.875,9.560},{21.685,8.549},{10.698,5.982},{17.618,6.034},{10.671,5.858},{9.214,3.858},{15.241,10.137},{30.114,11.313},{9.476,4.343},{6.075,4.023},{12.059,4.817},{14.385,4.930},{14.657,5.013},{11.901,4

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 09:58:09

mathematica作图的错误fp = {{23.604,9.983},{26.875,9.560},{21.685,8.549},{10.698,5.982},{17.618,6.034},{10.671,5.858},{9.214,3.858},{15.241,10.137},{30.114,11.313},{9.476,4.343},{6.075,4.023},{12.059,4.817},{14.385,4.930},{14.657,5.013},{11.901,4
mathematica作图的错误
fp = {{23.604,9.983},{26.875,9.560},{21.685,8.549},{10.698,
5.982},{17.618,6.034},{10.671,5.858},{9.214,3.858},{15.241,
10.137},{30.114,11.313},{9.476,4.343},{6.075,4.023},{12.059,
4.817},{14.385,4.930},{14.657,5.013},{11.901,
4.064},{11.214,4.044},{15.336,6.168},{7.381,4.353},{17.426,
5.157},{12.677,4.858},{16.192,8.941},{16.442,6.199}}
gp = ListPlot[fp]
Fit[fp,{1,x},x]
为什么显示出来会出现负值,并且做不出图,错误提示为General::ivar:1 is not a valid variable.

mathematica作图的错误fp = {{23.604,9.983},{26.875,9.560},{21.685,8.549},{10.698,5.982},{17.618,6.034},{10.671,5.858},{9.214,3.858},{15.241,10.137},{30.114,11.313},{9.476,4.343},{6.075,4.023},{12.059,4.817},{14.385,4.930},{14.657,5.013},{11.901,4
没有显示负值啊...
那个,不是说坐标轴以下的就是负值,你看看坐标轴的刻度嘛.这是mathematica为了显示"美观"而自动调整的坐标轴刻度,要手动调整下可以用:
gp = ListPlot[fp,PlotRange -> {{0,31},{0,12}}]
就很明显了.
至于作图,直接用
Plot[Fit[fp,{1,x},x],{x,0,31}]
是不行的,因为计算优先级的问题...这个不用管的太多,要学的话也不是一两句话就能说清楚的.总之,你改成:
Plot[Evaluate[Fit[fp,{1,x},x]],{x,0,31}]
就好了.
要把两个图像画在一起,再用(这里假设两个图像输出命令分别是第二第三个):
Show[%2,%3]