MATLAB: [SOLVED] How to customise a vector to run in a certain order

chemicalengineeringenthalpyheat exchangersvectors

I'm currently designing a co-current flow heat exchanger, and I've created a MATLAB code to observe how the specific enthalpy of one stream affects the temperature difference between the two streams. Part of my MATLAB code is shown below:
H1=107;
H2=1087;
H3=3638;
H4=2658;
Those are the 4 stream specific enthalpies I'm using. Stream 1's enthalpy goes from H1 to H2, because it's being heated up.
However, stream 2's specific enthalpy is decreasing from H3 to H4, because it's cooling down
I've defined my step size as:
dH1=((H2-H1)/1000);
dH2=((H3-H4)/1000);
This was done to split each enthalpy range into 1000 equal steps, so the step sizes are different, but there's an equal number of steps for both streams
I then have a vector set up, Hi, to vary stream 1's enthalpy between H1 and H2, for a step size of dH1. Stream 2 also has a vector, Ho, to vary its enthalpy from H3 to H4, with a step size of dH2
H_i=[H1:dHi:H2]
H_o=[H4:dHo:H3]
The only issue is that, because H4 has a smaller value than H3, whenever I try and run the script, it runs H1->H2 and H4->H3. But I want it to run H1->H2 and H3-H4, so that stream 1 increases whilst the other decreases

Best Answer

H_i = linspace(H1, H2, 1000+1);
H_o = linspace(H3, H4, 1000+1);
The +1 form corresponds to the code you had before, which would generate 1001 values.