MATLAB: How to change color line of mutiple result line plot in one graph

colorMATLAB

how to change color line of mutiple result line plot in one graph.I want to differentiate frequency result into 3 different colour.Thank you
%% Import data from spreadsheet
% Script for importing data from the following spreadsheet:
%


% Workbook: C:\Users\USER\Desktop\clay 2.xlsx Worksheet: xyToExcel
%
% To extend the code for use with different selected data or a different
% spreadsheet, generate a function instead of a script.
% Auto-generated by MATLAB on 2020/06/11 20:50:38
%% Import the data
clay2 = xlsread('C:\Users\USER\Desktop\clay 2.xlsx','xyToExcel');
%% Clear temporary variables

clearvars raw;
%% Allocate imported array to column variable names
Time = [clay2(:,1); clay2(:,3);clay2(:,5)];
Acceralation = [clay2(:,2); clay2(:,4);clay2(:,6)];
%% Clear temporary variables
clearvars data raw;
figure(1)
%Acceleration vs Time
subplot(2,1,1);
plot(Time,Acceralation);
title('Time Domain')
xlabel('Time (s)')
ylabel('Acceleration')
%Frequency Domain
L = length(Time); % Signal length
n = 2^nextpow2(L); %
Y = fft(Acceralation,n); %Convert acceleration to freq domain
subplot(2,1,2);
plot(1:n,abs(Y));
title('Frequency Domain')
xlabel('Frequency (f)')
ylabel('|(Amplitude)|')

Best Answer

Demo example:
x = 1:100 ;
y = rand(size(x)) ;
figure
hold on
plot(x(x<=25),y(x<=25),'r')
plot(x(x>25 & x <=50),y(x>25 & x <= 50),'b')
plot(x(x>50),y(x>50),'g')