2017-02-17 31 views
0

我有四個SFIT對象,我與情節:改變從SFIT表面圖的顏色MATLAB

figure; 
hold on; 
plot(f1); 
plot(f2); 
plot(f3); 
plot(f4); 

這繪製一個三維曲面。 但是我想給每個表面一個獨特的顏色,就像它在繪圖函數中很常見一樣。

plot(f1,'r'); 

但是,如果我這樣做是在這裏,我得到以下錯誤:

Error using plot No value was given for 'r'. Name-value pair arguments require a name followed by a value.

Error in sfit/plot>iParseInputs (line 231) p.parse( parameterValuePairs{:});

Error in sfit/plot (line 44) [XY, Z, in, out, style, level, hParent] = iParseInputs(obj, varargin{:});

這表明,這通常是通過給予指示的顏色,像放慢參數「R」或辦什麼事必須有一個字符串給,但哪一個?我已經嘗試了'Color'或'LineColor'之類的東西,但這些都不被識別

簡化問題:我想要代表擬合對象的平面具有一種顏色。每架飛機都有不同的一架。

回答

1

從這個鏈接:

https://uk.mathworks.com/matlabcentral/answers/153208-how-can-i-make-the-contour-plot-of-an-sfit-object-resemble-the-plot-generated-by-the-contour-com

你可以嘗試

f1 = fit([x y], z, 'poly23'); 
ph = plot(f1, 'Style', 'Contour'); 
set(ph, 'Fill', 'off', 'LineColor', 'auto'); 

的文檔set

https://uk.mathworks.com/help/matlab/ref/set.html


編輯

以上建議僅顯示2D情節,看到前面的SO回答3D情況:

MATLAB - Plot multiple surface fits in one figure

對您的相關代碼:

figure; 
h = plot(f1); 
set(h(1),'FaceColor','r'); 

因此,您正在尋找的「魔法詞」是'FaceColor',與set(上面提到的)結合使用, 。

+0

謝謝你的回答,但是這不完全是我想要的。首先使用繪圖(f1,'樣式','輪廓'),只會導致一個2D繪圖,我有一個3D繪圖。當簡單地使用繪圖(f1) - 因此繪圖仍然是3D時,調用set的函數會給出錯誤:「Surface類沒有填充屬性」 – Kev1n91

+0

@ Kev1n91嗯,看我的編輯 – Wolfie

+0

謝謝,這個鏈接是一個矯枉過正的點滴,但我找到了正確的路線,簡單地說:figure; h = plot(f1);設置(h(1),'FaceColor','r')。我不確定這個問題是否重複。但是,如果您可以在答案中插入該代碼段,我會接受它。 – Kev1n91