Making function to calculate value when user inputs date
显示 更早的评论
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 个评论
Jan
2012-7-31
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.
回答(1 个)
Honglei Chen
2012-4-6
0 个投票
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
类别
在 帮助中心 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!