2016-03-09 41 views
1
xCoordinates = {45, 40, 35, 30, 25, 20, 15, 10, 5, 0} 
yCoordinates = {0.6, 1.3, 1.5, 2.4, 5, 5.2, 5.3, 6, 6.4, 6.6} 
plotData = [email protected]{xCoordinates, yCoordinates} 
Show[ListPlot[plotData], Plot[Fit[plotData, {1, x}, x], {x, 0, 45}]] 

有效的變量錯誤我爲了執行這些並得到了3個錯誤說:「一般 - 伊娃:......是不是一個變量」,那麼常規::停止:在此計算過程中,General :: ivar的進一步輸出將被抑制。 顯示ListPlot,但沒有Fit線。任何人都可以請解釋我的代碼中的錯誤,以及這個錯誤的含義是什麼?一般 - 伊娃:......是不是在數學

編輯:另外生成的消息

RGBColor called with 1 argument; 3 or 4 arguments are expected. 

Coordinate Skeleton[10] should be a pair of numbers, or a Scaled or Offset form. 

這分別意味着什麼?

回答

1

請參閱Plot上的詳細信息部分。

「劇情具有屬性HoldAll並僅X分配具體的數值後計算˚F」。

要解決該問題,請評估Plot函數以外的擬合。

xCoordinates = {45, 40, 35, 30, 25, 20, 15, 10, 5, 0}; 
yCoordinates = {0.6, 1.3, 1.5, 2.4, 5, 5.2, 5.3, 6, 6.4, 6.6}; 
plotData = [email protected]{xCoordinates, yCoordinates}; 
fit = Fit[plotData, {1, x}, x]; 
Show[ListPlot[plotData], Plot[fit, {x, 0, 45}]] 

enter image description here

+0

謝謝!你能解釋一下錯誤的含義嗎? – Pavel

+1

從文檔:「['HoldAll'](https://reference.wolfram.com/language/ref/HoldAll.html)是一個屬性,它指定函數的所有參數都將以未評估的形式進行維護。 「這導致'Plot'報告各種無效變量([ivar](http://reference.wolfram.com/language/ref/message/General/ivar.html))錯誤。 –

+0

或者使用Evaluate:'Show [ListPlot [plotData], Plot [Evaluate @ Fit [plotData,{1,x},x],{x,0,45}]]' – tomd

相關問題