Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Polynomial Equation with different colors plot with code



Code: 

% here is just a draft. With this idea, continue with other variants of

% this code.

 

clear; clc;

x=linspace(0,5,100);

y=x.^3-7*x.^2+14*x-6;

 

colors = {'r','y','b','y','r','b','g','r'};

figure(10);

grid on

hold on

for dd=1:length(colors)

    a = floor(1+(dd-1)*length(x)/length(colors));

    b = floor(dd*length(x)/length(colors));   

    plot(x(a:b),y(a:b),colors{dd},'LineWidth',3)

    hold on

end

hold off

title('y(x) = x.^3-7*x.^2+14*x-6')

axis([0 5 -6 14])

 

saveas(figure(10),'graph_segmented_color','png')

 




Join us on Telegram: https://t.me/matlabcastor

No comments

Popular Posts