Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB QUESTION How can I make a list of dates imported from EXCEL to be displayed on a matlab graph as month and year. %%

MATLAB QUESTION

How can I make a list of dates imported from EXCEL to be displayed on a matlab graph as month and year.

%% Import data from spreadsheet % Script for importing data from the following spreadsheet: % % Workbook: % /Users/joshuahansen/Downloads/Assignment2_8761720_1947-1979.xlsx % Worksheet: Sheet1 % % To extend the code for use with different selected data or a different % spreadsheet, generate a function instead of a script.

% Auto-generated by MATLAB on 2017/09/14 11:03:21 clear all; %% Import the data

[~, ~, raw] = xlsread('/Users/joshuahansen/Downloads/Assignment2_8761720_1947-1979.xlsx','Sheet1'); raw = raw(2:end,:); raw(cellfun(@(x) ~isempty(x) && isnumeric(x) && isnan(x),raw)) = {''};

%% Replace non-numeric cells with NaN R = cellfun(@(x) ~isnumeric(x) && ~islogical(x),raw); % Find non-numeric cells raw(R) = {NaN}; % Replace non-numeric cells

%% Create output variable data = reshape([raw{:}],size(raw));

%% Allocate imported array to column variable names Year1 = data(:,1); Month1 = data(:,2); MSL1 = data(:,3); Date = data(:,4);

%% Clear temporary variables clearvars data raw R; %% x = Date; y = MSL1; T = readtable('/Users/joshuahansen/Downloads/Assignment2_8761720_1947-1979.xlsx');

% T.Date = datetime(x,'ConvertFrom','excel') % I found this online, however I dont know how to make it work. dn=datetime(x,'InputFormat','MM/dd/yyyy');

format LONG;

b1 = x\y X = [ones(length(x),1) x]; b = X\y

yCalc1 = b1*x; yCalc2 = X*b; plot(x,yCalc2,'--') legend('Data','Slope','Slope & Intercept','Location','best'); scatter(x,y) hold on plot(x,yCalc1) xlabel('Date') ylabel('MSL') title('Linear Regression Relation Between Date and MSL') grid on

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

Define employer choice strategy.

Answered: 1 week ago

Question

what are the provisions in the absence of Partnership Deed?

Answered: 1 week ago