Plotting from an array at an interval
Show older comments
I am trying to plot two columns in an array. The x-axis represents months in the year and the y-axis is temperature values from each month. This data loops in my array in intervals of 12. I am trying to plot each year ( 12 months) as a seperate line on the plot. How can i do this?
My current code plots this as one line thorughout my plot.
for a = 1:length(skrar)
figure;
LH = load(skrar(a).name);
uni = unique(LH(:,2));
plot(LH(:,3),LH(:,4),'Color',rand(1,3));
title(LH(1,1) + " Median " + LH(1,2) + " til " + LH(end,2))
manudir = {'Jan';'Feb';'Mar';'Apr';'Maí';'Jún';'Júl';'Ágú';'Sep';'Okt';'Nóv';'Des'};
set(gca,'xtick',[1:12],'xticklabel',manudir)
ylabel('Hitastig[°C]')
end
An example of my data looks like this:
422 1882 1 -0.8 4
422 1882 2 -5.8 4
422 1882 3 -5.5 4
422 1882 4 -3.1 4
422 1882 5 2.0 4
422 1882 6 4.5 4
422 1882 7 6.1 4
422 1882 8 4.1 4
422 1882 9 5.3 4
422 1882 10 5.0 4
422 1882 11 -1.8 4
422 1882 12 -3.9 4
422 1883 1 -1.4 4
422 1883 2 -0.8 4
422 1883 3 -2.9 4
422 1883 4 3.0 4
422 1883 5 1.9 4
422 1883 6 8.9 4
422 1883 7 10.1 4
422 1883 8 7.7 4
422 1883 9 7.2 4
422 1883 10 2.9 4
422 1883 11 -0.2 4
422 1883 12 -1.0 4
Column 3 is the months and column 4 is the temperature
My current plot looks like this:

Accepted Answer
More Answers (0)
Categories
Find more on Annotations 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!