Hi,how do I isolate month June from the whole 2014 year in the code below.Many thanks!!
Show older comments
clear
close all
clc
filename='DevonportTides2014.txt';
A=readtable(filename,'headerlines',1)
subplot(2,1,1)
hold on
data=table2array(A);
Years =data(:,1);
Months =data(:,2);
Days =data(:,3);
Hours =data(:,4);
Minutes =data(:,5);
Seconds =data(:,6);
tide =data(:,7);
dnum=datenum(Years,Months,Days,Hours,Minutes,Seconds);
plot(dnum,tide,'k')
datetick
grid on
title('Devonport Tidal Height (2014)')
ylabel('[m rel.CD]')
xlabel('Month')
datetick
set(gca,'Fontsize',14,'Linewidth',4)
1 Comment
Image Analyst
on 20 Dec 2022
Unfortunately you forgot to attach 'DevonportTides2014.txt', and I didn't look beyond that. I'll check back later for it.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Answers (1)
Image Analyst
on 20 Dec 2022
Put this in there after your code.
% Now let's pull out just June
juneRows = A.Month == 6;
juneTable = A(juneRows, :)
Then just do whatever you want with juneTable, like perhaps what you did with (the poorly-named) A.
7 Comments
kolberg
on 20 Dec 2022
Image Analyst
on 20 Dec 2022
Isn't it
plot(Days, tide,'k')
xlabel('Days')
ylabel('Tide')
kolberg
on 20 Dec 2022
Hannah
on 21 Dec 2022
Hi, I'm currently working on the same piece of work. Not quite sure on what to put eithertside of the : in juneTable = A(juneRows, :)
Currently this is what my plot looks like and I'm really not sure how to fix it!
This is my current code:
% Subplot June 2014
juneRows=A.Month==6;
junetable=A(juneRows,:);
subplot(2,1,2)
plot(Days,tide, 'k')
title('Devonport Tidal Height (June 2014)')
ylabel('(m rel. CD)')
xlabel('Days')
set(gca,'FontSize',12,'LineWidth',1.7)
grid on

Image Analyst
on 21 Dec 2022
@Hannah, what would "fixed" look like to you?
Hannah
on 21 Dec 2022

Image Analyst
on 21 Dec 2022
@Hannah your data is undoubtedly different than @kolberg's. So start your own question so we don't keep emailing @kolberg who has most likely already found the answer for his/her specific data. Perhaps he/she want to post it here.
If you have any more questions, then attach your data and code to read it (or my code) with the paperclip icon after you read this:
Categories
Find more on Thermal Analysis 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!