%-------------------------------------------------------------------------%
%-------------------------  Temperataure profiles  -----------------------%
%---------------------  at different operation point  --------------------%

clear all
clc
clf
N=41;
n=1:N;
TC_location=15;

Tprofile(1,:)= [-0.712000452394591,-0.759722853901110,...
    -0.820905061012297,-0.898965699851658,-0.997950099629406,...
    -1.12249202773961,-1.27766234722930,-1.46865018305039,...
    -1.70022610437326,-1.97596680047417,-2.29728945015404,...
    -2.66245151821948,-3.06578863007121,-3.49752304294378,...
    -3.94439914231242,-4.39116200561580,-4.82257203471744,...
    -5.22541534657029,-5.58997152928930,-5.91063626965700,...
    -6.18571931789921,-6.49674059616422,-6.84695417244336,...
    -7.23219639029543,-7.64523560999299,-8.07607175201724,...
    -8.51277795855299,-8.94276552293781,-9.35420218509580,...
    -9.73725546446957,-10.0848992081406,-10.3931762883385,...
    -10.6609747785308,-10.8894812492371,-11.0815004599050,...
    -11.2407949622925,-11.3715367550897,-11.4779055207859,...
    -11.5638282982097,-11.6328351490391,-11.6879995476054];

Tprofile(2,:)= [-0.712000452394591,-0.759722853901053,...
    -0.820905061012297,-0.898965699851601,-0.997950099629350,...
    -1.12249202773950,-1.27766234722918,-1.46865018305022,...
    -1.70022610437303,-1.97596680047388,-2.29728945015376,...
    -2.66245151821914,-3.06578863007081,-3.49752304294339,...
    -3.94439914231202,-4.39116200561540,-4.82257203471710,...
    -5.22541534656995,-5.58997152928896,-5.91063626965678,...
    -6.18571931789904,-6.49674059616399,-6.84695417244308,...
    -7.23219639029509,-7.64523560999271,-8.07607175201690,...
    -8.51277795855270,-8.94276552293752,-9.35420218509552...
    ,-9.73725546446934,-10.0848992081404,-10.3931762883383,...
    -10.6609747785306,-10.8894812492370,-11.0815004599049,...
    -11.2407949622924,-11.3715367550896,-11.4779055207858,...
    -11.5638282982097,-11.6328351490390,-11.6879995476054];

Tprofile(3,:)= [-0.711971700810295,-0.759808132335877,...
    -0.820761970186425,-0.899159521093395,-0.997720016064136,...
    -1.12273874519201,-1.27741991530155,-1.46886983606282,...
    -1.70004202665484,-1.97610962454786,-2.29718685204017,...
    -2.66251980683251,-3.06574653861009,-3.49754715702176,...
    -3.94438631208698,-4.39116840960224,-4.82256905195311,...
    -5.22541667499417,-5.58997097943274,-5.91063649469817,...
    -6.18571924007870,-6.49674062430228,-6.84695416699140,...
    -7.23219639478970,-7.64523561126873,-8.07607175388756,...
    -8.51277795993724,-8.94276552412930,-9.35420218603451,...
    -9.73725546519921,-10.0848992086878,-10.3931762887376,...
    -10.6609747788139,-10.8894812494328,-11.0815004600372,...
    -11.2407949623798,-11.3715367551463,-11.4779055208219,...
    -11.5638282982324,-11.6328351490531,-11.6879995476140];

Tprofile(4,:)= [-0.665286918727475,-0.694400534615909,-0.733576623759632,...
    -0.785758433353578,-0.855587815002025,-0.947707070621618,...
    -1.06935011977674,-1.22739774895922,-1.43133066439850,...
    -1.68936804756390,-2.01029607736729,-2.39906623866841,...
    -2.85669124645949,-3.37655565885422,-3.94438767927136,...
    -4.53830278358367,-5.13215245636462,-5.69972474400691,...
    -6.21928293644953,-6.67643133162113,-7.06487207205976,...
    -7.67723916225202,-8.28537622604699,-8.86481188757256,...
    -9.39551969348969,-9.86429955384597,-10.2653073691407,...
    -10.5990360610658,-10.8704749395010,-11.0871607720459,...
    -11.2575706199522,-11.3900180003707,-11.4920205316938,...
    -11.5700231722454,-11.6293510260039,-11.6742896919820,...
    -11.7082230507675,-11.7337859475190,-11.7530089872942,...
    -11.7674452242825,-11.7782757683865];

Tprofile(5,:)=[-0.712015632716316,-0.761607520841551,-0.828037692252053,...
    -0.915725309507764,-1.03200578539133,-1.18310267241884,...
    -1.37910774003359,-1.62755239919085,-1.93834800941329,...
    -2.31640962287378,-2.76436692231732,-3.27644746407935,...
    -3.83995747326406,-4.43373685462734,-5.03197504681771,...
    -5.60784922081768,-6.13848371448893,-6.60805273806119,...
    -7.00895930518777,-7.34089912639348,-7.60882539360358,...
    -8.21990729359743,-8.80447496522680,-9.34183193183674,...
    -9.81799550947795,-10.2264089792316,-10.5670365905410,...
    -10.8445545098531,-11.0663740021073,-11.2409801471966,...
    -11.3767730778483,-11.4813925306918,-11.5614126427737,...
    -11.6222787563310,-11.6683805068345,-11.7031876989030,...
    -11.7294039438359,-11.7491136814658,-11.7639114515180,...
    -11.7750099688133,-11.7833275787413];

Tprofile(6,:)=[-0.613634332278764,-0.619789907059669,-0.628046994336501,...
    -0.639310988834268,-0.654328132094406,-0.674808597209903,...
    -0.702049492789683,-0.738991846852173,-0.788024529442509,...
    -0.853863066806753,-0.940757454644142,-1.05571972972041,...
    -1.20547904075829,-1.39920589463247,-1.64535462011168,...
    -1.95282716511070,-2.32751982896906,-2.77151109282499,...
    -3.27990468324828,-3.84004256573479,-4.43141603309346,...
    -4.73977086735204,-5.11454835981607,-5.55850195126538,...
    -6.06866024698729,-6.63482675807296,-7.23936681517523,...
    -7.85885790045569,-8.46747090320741,-9.04113603378079,...
    -9.56113181264459,-10.0160420771753,-10.4018188673770,...
    -10.7204279108397,-10.9778645910006,-11.1822185420075,...
    -11.3421642940439,-11.4659763699535,-11.5610005048232,...
    -11.6334520966308,-11.6884166426122];

Tprofile(7,:)= [-0.711996865502499,-0.756577641249578,-0.809920026713087,...
    -0.873587472460372,-0.949013526484180,-1.03804001131840,...
    -1.14211761613967,-1.26302159595764,-1.40185459453915,...
    -1.55971589374610,-1.73674038757952,-1.93258620926298,...
    -2.14573058230485,-2.37382613155097,-2.61340661016362,...
    -2.86026852464528,-3.10959154285547,-3.35639853981382,...
    -3.59588850189419,-3.82383274267647,-4.03682800886969,...
    -4.33468119369326,-4.70353600022503,-5.14882793634484,...
    -5.67015655425797,-6.25902869239474,-6.89787689218895,...
    -7.56129253088147,-8.21966430198233,-8.84426237634085,...
    -9.41201099677204,-9.90836967605225,-10.3277522854643,...
    -10.6719964800444,-10.9479193875272,-11.1648923087197,...
    -11.3329586310160,-11.4616292720525,-11.5592599808067,...
    -11.6328360255054,-11.6879995170065];

Tprofile(8,:)= [-0.712005042794374,-0.758186207213498,-0.815562005839524,...
    -0.886357055873248,-0.973456360277055,-1.07956931052269,...
    -1.20809557025069,-1.36182934535151,-1.54380994163182,...
    -1.75583004833163,-1.99896475800591,-2.27225539085345,...
    -2.57299158010119,-2.89604069467907,-3.23435331523285,...
    -3.57925476684039,-3.92142794550233,-4.25181582942651,...
    -4.56259410544237,-4.84781425229113,-5.10372479190858,...
    -5.42069372509474,-5.79438899470188,-6.22393543353059,...
    -6.70352834066136,-7.22191941656195,-7.76297921016243,...
    -8.30746108204892,-8.83563090039917,-9.33003845760271,...
    -9.77763950647841,-10.1707768097672,-10.5069970721875,...
    -10.7880490063066,-11.0185347655178,-11.2046059025866,...
    -11.3529252336345,-11.4699597524049,-11.5615718356969,...
    -11.6328352641345,-11.6879993491609];

Tprofile(9,:)= [-0.711998903351912,-0.761193566492807,-0.826186294381103,...
    -0.911657626866315,-1.02325450731610,-1.16778176525116,...
    -1.35278251419845,-1.58630861024074,-1.87573122629709,...
    -2.22657567365286,-2.64049014339554,-3.11357028787387,...
    -3.63499840137240,-4.18725852500614,-4.74799963450261,...
    -5.29348625873968,-5.80246526296497,-6.25923811933831,...
    -6.65505051138115,-6.98776150456325,-7.26035332826200,...
    -7.53848875145371,-7.83927684765354,-8.15820898065067,...
    -8.48938417729312,-8.82589147590062,-9.16036233073913,...
    -9.48560422448372,-9.79520274333720,-10.0839887568117,...
    -10.3483059029637,-10.5860652349695,-10.7966196092035,...
    -10.9805173916666,-11.1392006460915,-11.2747024928066,...
    -11.3893802490069,-11.4857025995383,-11.5660946628196,...
    -11.6328357149400,-11.6879999312177];

Tprofile(10,:)= [-0.712005144059560,-0.762612454549526,-0.831514778712290,...
    -0.924593977091433,-1.04979575114663,-1.21614026920935,...
    -1.43485893282138,-1.71716156185011,-2.07423699625701,...
    -2.51340960750247,-3.03615184728261,-3.63407464846659,...
    -4.28797309320908,-4.96870877148939,-5.64208193162551,...
    -6.27529003786418,-6.84302402777604,-7.33070908965090,...
    -7.73445500013480,-8.05862017338023,-8.31254544192348,...
    -8.53364115250810,-8.76514844442181,-9.00396767056219,...
    -9.24656814674881,-9.48918836032112,-9.72806557719815,...
    -9.95966569977253,-10.1808840899486,-10.3891942903624,...
    -10.5827320300657,-10.7603135510562,-10.9213971782347,...
    -11.0660032969279,-11.1946100036785,-11.3080403912178,...
    -11.4073539835737,-11.4937506233234,-11.5684911123251,...
    -11.6328357207544,-11.6879995924957]; 

TC=[-3.9444,-3.9444,-3.9444,-3.9444,-5.0320,-1.6454, -2.61340,-3.2344,-4.7480,-5.6421];
%%
figure (1)
for i=1:10
    if i<3
        plot(n,Tprofile(i,:), '--','color', [0 0 1], 'MarkerFaceColor','g','HandleVisibility','off')
        hold on
    elseif i==3
        plot(n,Tprofile(i,:), '-mo','color', [0 0 1], 'MarkerFaceColor','g','MarkerSize',5 )
        hold on
    elseif i>3 && i<7
        red=(8-i)/4;
        green=0;
        blue=0.4;
        plot(n,Tprofile(i,:),'-.', 'color', [red green blue])
        hold on
    else
        red=0;
        green=(14-i)/7;
%         blue= 1-0.1*i;
        blue=(i-7)/5;
        plot(n,Tprofile(i,:), 'color', [red green blue])
        hold on
    end
end
for i=4:10
    if i==4
        red=(8-i)/4;
        green=(i-4)/4;
        blue= 0.5;
        plot(TC_location,TC(i), 'rs','color', [0 0 1],'MarkerFaceColor',[red green blue])
        hold on
    elseif i>4 && i<7
        red=(9-i)/5;
        green=0;
        blue=0.1;
        plot(TC_location,TC(i), 'rs','color', [red green blue],'MarkerFaceColor',[red green blue])
        hold on
    else 
        red=0;
        green=(13-i)/6;
        blue=(i-7)/5;
        plot(TC_location,TC(i), 'rs','color', [red green blue],'MarkerFaceColor',[red green blue])
        hold on
    end
        
end
% plot(n,Tprofile_1, n,Tprofile_2, n, Tprofile_3, n,Tprofile_4,...
%     TC,-3.9444, 'o',n, Tprofile_5, TC,-2.5130, 'o',...
%     n, Tprofile_6, TC,-3.2344, 'o', n, Tprofile_7, TC, -4.7480, 'o',...
%     n, Tprofile_8, TC,  -5.6421, 'o')
% %hold on
% %'LineWidth', 5
legend_h=legend('Operation point 1-3', 'Operation point 4a', 'Operation point 4b',...
    'Operation point 4c', 'Operation point 5', 'Operation point 6',...
    'Operation point 7', 'Operation point 8',...
    'Temperature controllers in operation points 1-4a',...
    'Temperature controller in operation point 4b',...
    'Temperature controller in operation point 4c',...
    'Temperature controller in operation point 5',...
    'Temperature controller in operation point 6',...
    'Temperature controller in operation point 7',...
    'Temperature controller in operation point 8');
set(legend_h, 'Fontsize', 8)
%title('Temperatureprofiles','BackgroundColor',[.99 .99 .99])
xmin=n(1);
xmax=n(end);
ymin=min(Tprofile(1,end),Tprofile(end,end));
ymax=max(Tprofile(1,1),Tprofile(end,1));    
axis([xmin xmax ymin ymax])
grid on
xlabel('Stage number')
ylabel('Temperature [oC]')