Plotting a Constant Section for a Piecewise Function
Show older comments
I am trying to plot a piecewise function. The version of the software I have does not allow me to ue the built in function so I have to it a round-a-bout way. Below is the code I have for the figure.
% Figure generation for algorithm #1
figure(1) % Generates plots of heating calibration data with model overlay
subplot(2,1,1) % Positioning of 'clean' heating calibration data
plot(Time(:,1), Temperature(:,1), 'k-') % Plots calibration data
title({'Clean Heating Calibration Data as a Function of Time', 'with Piecewise Model Overlay'})
xlabel('Time (sec)')
ylabel('Temperature (deg C)')
hold on
plot(Time_Top_1a, y1_L(1), 'r--') % Plots constant section of piecewise function
hold on
plot(Time_Bot_1a, HeatingClean_Expected_Temperatures1, 'r--') % Plots piecewise model
legend('Calibration Data', 'Piecewise Model Estimates', 'location', 'best')
grid on
hold off
The first plot is some actual data. The two plots following that plot a model of the actual data. The very bottom plot works fine. I am having trouble with the middle one. It is suppossed to plot a constant value, defined by y1_L(1), over a range of times, defined by Time_Top_1a. When I run the script, this line does not show up but the legend on the graph acknowledges its exisitence. Also, when I change the plotting style from line to data marker, it shows up on the plot but I need it to be a line that matches the style ofthe very bottom plot. Any help would be greatly appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

