Hi,how do I isolate month June from the whole 2014 year in the code below.Many thanks!!

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 comentario

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:

Iniciar sesión para comentar.

Respuestas (1)

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 comentarios

Thank you!Will try to name the things right.Much appreciated.Need to figure out how to get days on x-axis now.
Isn't it
plot(Days, tide,'k')
xlabel('Days')
ylabel('Tide')
Need to have dnum on x axis and probably play with datetick.Thanks again!!!
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
@Hannah, what would "fixed" look like to you?
Hi @Image Analyst, it'd be like this tidal curve graph but focussed only on the month of June
@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:

Iniciar sesión para comentar.

Categorías

Más información sobre Thermal Analysis en Centro de ayuda y File Exchange.

Preguntada:

el 20 de Dic. de 2022

Comentada:

el 21 de Dic. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by