change color when i plot more surface fit

20 Ansichten (letzte 30 Tage)
Giovanni Massaria
Giovanni Massaria am 18 Okt. 2022
Bearbeitet: Kevin Holly am 18 Okt. 2022
Hi everyone, i need to change the color of the different surfaces that i found whit fit, adding a simple color command don't work, so how can i have different colors in the two surfaces? the first blue and the second red for example
fig10=figure(10);
[xData, yData, zData] = prepareSurfaceData( comfortval, cval, dval );
ft = fittype( 'poly44' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Robust = 'Bisquare';
fitresult = fit( [xData, yData], zData, ft, opts );
h1 = plot( fitresult, [xData, yData], zData );
hold on
[xData, yData, zData] = prepareSurfaceData( comfortvalBL, cvalBL, dvalBL );
ft = fittype( 'poly44' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Robust = 'Bisquare';
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
h2 = plot( fitresult, [xData, yData], zData); % if i add ,'r' at the end the programm don't work
hold on

Antworten (1)

Kevin Holly
Kevin Holly am 18 Okt. 2022
Bearbeitet: Kevin Holly am 18 Okt. 2022
fig10=figure(10);
xData = rand(30,1);
yData = rand(30,1);
zData = rand(30,1);
ft = fittype( 'poly44' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Robust = 'Bisquare';
fitresult = fit( [xData, yData], zData, ft, opts );
h1 = plot( fitresult, [xData, yData], zData );
h1(1).FaceColor = 'b';
hold on
xData = rand(30,1);
yData = rand(30,1);
zData = rand(30,1);
ft = fittype( 'poly44' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Robust = 'Bisquare';
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
h2 = plot( fitresult, [xData, yData], zData);
h2(1).FaceColor = 'r';

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by