Making function to calculate value when user inputs date
Ältere Kommentare anzeigen
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 Kommentar
Jan
am 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.
Antworten (1)
Honglei Chen
am 6 Apr. 2012
0 Stimmen
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
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!