Making function to calculate value when user inputs date
Show older comments
Hello! Im currently attempting to make a function that will have input arguments as "(month, day)" and return the value within a piece of excel data that corresponds with 7 days (columns) a week and 53 weeks (rows). I started with the following:
function [ ] = MonthDay( data (excel file),Month,Day )
%User Enters in day month and excel data and returns value within %that cell
Month=input('Please Enter the Month and indicate your input between two Apostrophes \n')
Day=input(' Please enter the Day of the Month and indicate input between two Apostrophes\n')
if (Month=='January');
I simply cannot figure out how to convert the date to the value within the cell and am basically stuck. Any help would be greatly appreciated. Thank you. -John
1 Comment
Jan
on 31 Jul 2012
Please choose meaningful tags: all questions in the forum concern "matlab" or "matlab code".
Do not use == to compare strings, because it operates on the elements:
'a' = 'abca' % ==> [true, false, false, true]
'abca' = 'abca' % ==> [true, true, true, true]
Use strcmp instead.
Answers (1)
Honglei Chen
on 6 Apr 2012
0 votes
I think you need more information. Given only month and date, how can you figure out the weekday information? Or is it for a given year?
The following link should be helpful
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!