change color when i plot more surface fit

10 visualizaciones (últimos 30 días)
Giovanni Massaria
Giovanni Massaria el 18 de Oct. de 2022
Editada: Kevin Holly el 18 de Oct. de 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

Respuestas (1)

Kevin Holly
Kevin Holly el 18 de Oct. de 2022
Editada: Kevin Holly el 18 de Oct. de 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';

Categorías

Más información sobre Fit Postprocessing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by