EECS 1570 Winter 2021 Assignment 5 Due: Monday April 12 by 11:59 p.m. 1. This assignment is worth 6% of your final grade. 2. Submit your assignment electronically through eClass. Assignments submitted...

write a matlab program as asked in the file attached


EECS 1570 Winter 2021 Assignment 5 Due: Monday April 12 by 11:59 p.m. 1. This assignment is worth 6% of your final grade. 2. Submit your assignment electronically through eClass. Assignments submitted by email will not be accepted. 3. A list of files to submit is found at the end of this assignment. Organize your MATLAB programs as follows, with your student information, the question number, and your solution in the indicated locations. % 1570 - Winter 2021 – Assignment 5 % Last Name, First Names % Student Number % York email address % Question x solution clear; clc; clf; % fresh start put your solution here % *** end *** 4. To improve the readability of your MATLAB programs, ensure the statements are properly indented. This is a good habit to develop and is particularly important as your programs get more complex. Here's a quick way to get the proper indentation: (i) Open a script in the MATLAB Editor Window. (ii) Type Ctrl-A to select all the statements in the script. (iii) In the Editor ribbon, click the Smart Indent button. Questions 1. (8 points) The file stress_symptoms.txt (available on eClass with this assignment) contains data from research exploring the relationship between perceived stress and the symptoms of stress. The data are organized in a table with 108 rows and 4 columns: ID Stress Symptoms LnSymptoms 1 30 99 4.59512 2 27 94 4.54330 3 9 80 4.38203 4 20 70 4.24850 5 3 100 4.60517 6 15 109 4.69135 … … … … 107 27 97 4.57471 The first row is a header containing a text label that identifies the data in each column. The ID identifies the participants – first-year college students. The scores for Stress correspond to the perceived social and environmental stress for 107 participants The scores are based on the reported frequency and subjective estimate of the impact of recent life events. The scores for Symptoms are based on participants' responses to the Hopkins Symptom Checklist, assessing the presence or absence of 57 psychological symptoms. The LnSymptoms data are the log (base-e) of the Symptoms scores. More information on the data are found in the file stress_symptoms_readme.txt. In this question, we will explore the relationship between the scores for Stress and LnSymptoms. Is there a correlation between Stress and LnSymptoms? Can LnSymptoms be predicted from Stress? Write a MATLAB program (a5q1.m) that uses the readtable function to read the data in stress_symptoms.txt into a table T. Begin by computing and outputing in the Command Window some informative statistics, including the number of participants, the mean and standard deviation of the scores for Stress, Symptoms, and LnSymptoms, the correlation coefficient between the LnSymptoms and Stress, and the formula for the best-fitting line expressing LnSymptoms as a linear function of Stress. Here's the desired output: ============================== Stress vs. Symptoms Research ============================== Number of participants: xxx ------------------------------ Mean SD Stress xxxx xxxx Symptoms xxxx xxxx LnSymptoms xxxx xxxx ------------------------------ Correlation: LnSymptoms vs. Stress r = xxxxxx (xxxxx) Linear regression: y = mx + b LnSymptoms = xxxxxxx x Stress + xxxxxxx Replace the x's above with values computed from the data. Report the means and standard deviations with 1 decimal place. Output the three data lines in the table using a single fprintf statement with three formatting elements. Below the table, report the correlation, slope, and intercept with 4 decimal places. In parentheses after the correlation, include an assessment of the correlation: "weak" (if r < 0.4),="" "modest"="" (if="" 0.4=""><= r="">< 0.7), or "strong" (if r ≥ 0.7). the assessment must be determined from the correlation (i.e., not typed in to your script). next, generate a scatter plot as a matlab figure: include your name and student number as the title of the scatter plot and include x-axis and y-axis labels, as above. your scatter plot should appear as above, except using a shade of blue, instead of green. give the markers a light blue face colour and a dark blue edge colour. make the regression line thick (as above) and dark blue. add text giving the equation for the regression line and the squared correlation for the data.1 also, include a grey line from the equation to the regression line. see above. replace the black rectangles above with the computed values (with 4 decimal places). finally, include a statement in your program to save the plot in a file as a jpg image with 600 dpi resolution. name the file stress_symptoms.jpg. 2. (8 marks) in this question you will analyse the responses to the handedness questionnaire given in class earlier this semester. the data are in the file handedness_questionnaire.xlsx, available on eclass with this assignment. the file handedness_questionnaire_readme.txt provides additional information on the questionnaire, the organization of the data, and the method for computing the handedness score (h) for each respondent (i.e., you). are you left handed or right handed? perhaps you are ambidextrous. you will find out in this assignment question. download both of these files and study their contents. write a matlab program (a5q2.m) that uses the readtable function to read the data from handedness_questionaire.xlsx into a table t. perform the following analyses on the data. first, compute the handedness score (h) for the participants. send output to the command window showing the initials and handedness score. organize the output in the three groups, revealing the participants who are left handed, right handed, and ambidextrous. here's an abbreviated look at the desired output: left: xxx (xxx) xxx (xxx) xxx (xxx) (etc.) right: xxx (xxx) xxx (xxx) xxx (xxx) (etc.) ambidextrous: xxx (xxx) xxx (xxx) xxx (xxx) (etc.) on each line above, replace the 1st group of x's with the participant's initials and the 2nd group with the participant's handedness score (in parentheses). repeat, as necessary, within each group. second, generate a nicely-formatted summary of the handedness analysis: 1 when used with a linear prediction question, the correlation (r) is commonly reported as the squared correlation (r2). the squared correlation represents the amount of variance explained by the model. ========================= summary ------------------------- left: xxx xxxx% right: xxx xxxx% ambidextrous: xxx xxxx% ------------------------- total: xxx 100.0% ========================= replace the x's above with values computed in your script. for each handedness category, the first value is the count (an integer) and the second value is the percent of all participants in the category (with 1 decimal place). the last value is the total number of participants (an integer). create the middle section of the table using a single fprintf statement with three formatting elements. third, create a matlab pie chart showing the results: replace the black boxes by the pie slices with the corresponding percentage of participants in each handedness category (with 0 decimal places). add text to the right of the pie indicating the total number of respondents. 3. (8 points) write a matlab program (a5q3.m) that uses a term-by-term trigonometric expansion to build up and graphically illustrate a non-sinusoidal periodic waveform known as a "square wave": the trigonometric expansion for a square wave is ??(??) = 4 ?? �sin(????) + 1 3 sin(3????) + 1 5 sin(5????) + . . . � , where ?? = 2???? a square wave of frequency f is built up by summing the sinusoidal waveform for the base frequency f with the odd harmonics of the waveform, each with decreasing amplitude as shown above. a perfect square wave is formed by extending the trigonometric expansion to an infinite number of terms. for your graphical demonstration, use just 10 terms and show the build-up of the waveform in a 1× 2 matlab subplot. in the left plot, show the sinusoids as they are added, one by one. in the right plot, show the result of summing the terms, as per the trigonometric expansion. create a sequence of 10 visualizations with a 500 ms pause between each. show the waveforms over two cycles (i.e., 4π). omit the frequency f since it is an arbitrary constant (e.g., 1). the basic method for graphing a sine wave is shown in example 3 in lecture 19. with just the 1st term, the plots 0.7),="" or="" "strong"="" (if="" r="" ≥="" 0.7).="" the="" assessment="" must="" be="" determined="" from="" the="" correlation="" (i.e.,="" not="" typed="" in="" to="" your="" script).="" next,="" generate="" a="" scatter="" plot="" as="" a="" matlab="" figure:="" include="" your="" name="" and="" student="" number="" as="" the="" title="" of="" the="" scatter="" plot="" and="" include="" x-axis="" and="" y-axis="" labels,="" as="" above.="" your="" scatter="" plot="" should="" appear="" as="" above,="" except="" using="" a="" shade="" of="" blue,="" instead="" of="" green.="" give="" the="" markers="" a="" light="" blue="" face="" colour="" and="" a="" dark="" blue="" edge="" colour.="" make="" the="" regression="" line="" thick="" (as="" above)="" and="" dark="" blue.="" add="" text="" giving="" the="" equation="" for="" the="" regression="" line="" and="" the="" squared="" correlation="" for="" the="" data.1="" also,="" include="" a="" grey="" line="" from="" the="" equation="" to="" the="" regression="" line.="" see="" above.="" replace="" the="" black="" rectangles="" above="" with="" the="" computed="" values="" (with="" 4="" decimal="" places).="" finally,="" include="" a="" statement="" in="" your="" program="" to="" save="" the="" plot="" in="" a="" file="" as="" a="" jpg="" image="" with="" 600="" dpi="" resolution.="" name="" the="" file="" stress_symptoms.jpg.="" 2.="" (8="" marks)="" in="" this="" question="" you="" will="" analyse="" the="" responses="" to="" the="" handedness="" questionnaire="" given="" in="" class="" earlier="" this="" semester.="" the="" data="" are="" in="" the="" file="" handedness_questionnaire.xlsx,="" available="" on="" eclass="" with="" this="" assignment.="" the="" file="" handedness_questionnaire_readme.txt="" provides="" additional="" information="" on="" the="" questionnaire,="" the="" organization="" of="" the="" data,="" and="" the="" method="" for="" computing="" the="" handedness="" score="" (h)="" for="" each="" respondent="" (i.e.,="" you).="" are="" you="" left="" handed="" or="" right="" handed?="" perhaps="" you="" are="" ambidextrous.="" you="" will="" find="" out="" in="" this="" assignment="" question.="" download="" both="" of="" these="" files="" and="" study="" their="" contents.="" write="" a="" matlab="" program="" (a5q2.m)="" that="" uses="" the="" readtable="" function="" to="" read="" the="" data="" from="" handedness_questionaire.xlsx="" into="" a="" table="" t.="" perform="" the="" following="" analyses="" on="" the="" data.="" first,="" compute="" the="" handedness="" score="" (h)="" for="" the="" participants.="" send="" output="" to="" the="" command="" window="" showing="" the="" initials="" and="" handedness="" score.="" organize="" the="" output="" in="" the="" three="" groups,="" revealing="" the="" participants="" who="" are="" left="" handed,="" right="" handed,="" and="" ambidextrous.="" here's="" an="" abbreviated="" look="" at="" the="" desired="" output:="" left:="" xxx="" (xxx)="" xxx="" (xxx)="" xxx="" (xxx)="" (etc.)="" right:="" xxx="" (xxx)="" xxx="" (xxx)="" xxx="" (xxx)="" (etc.)="" ambidextrous:="" xxx="" (xxx)="" xxx="" (xxx)="" xxx="" (xxx)="" (etc.)="" on="" each="" line="" above,="" replace="" the="" 1st="" group="" of="" x's="" with="" the="" participant's="" initials="" and="" the="" 2nd="" group="" with="" the="" participant's="" handedness="" score="" (in="" parentheses).="" repeat,="" as="" necessary,="" within="" each="" group.="" second,="" generate="" a="" nicely-formatted="" summary="" of="" the="" handedness="" analysis:="" 1="" when="" used="" with="" a="" linear="" prediction="" question,="" the="" correlation="" (r)="" is="" commonly="" reported="" as="" the="" squared="" correlation="" (r2).="" the="" squared="" correlation="" represents="" the="" amount="" of="" variance="" explained="" by="" the="" model.="========================" summary="" -------------------------="" left:="" xxx="" xxxx%="" right:="" xxx="" xxxx%="" ambidextrous:="" xxx="" xxxx%="" -------------------------="" total:="" xxx="" 100.0%="========================" replace="" the="" x's="" above="" with="" values="" computed="" in="" your="" script.="" for="" each="" handedness="" category,="" the="" first="" value="" is="" the="" count="" (an="" integer)="" and="" the="" second="" value="" is="" the="" percent="" of="" all="" participants="" in="" the="" category="" (with="" 1="" decimal="" place).="" the="" last="" value="" is="" the="" total="" number="" of="" participants="" (an="" integer).="" create="" the="" middle="" section="" of="" the="" table="" using="" a="" single="" fprintf="" statement="" with="" three="" formatting="" elements.="" third,="" create="" a="" matlab="" pie="" chart="" showing="" the="" results:="" replace="" the="" black="" boxes="" by="" the="" pie="" slices="" with="" the="" corresponding="" percentage="" of="" participants="" in="" each="" handedness="" category="" (with="" 0="" decimal="" places).="" add="" text="" to="" the="" right="" of="" the="" pie="" indicating="" the="" total="" number="" of="" respondents.="" 3.="" (8="" points)="" write="" a="" matlab="" program="" (a5q3.m)="" that="" uses="" a="" term-by-term="" trigonometric="" expansion="" to="" build="" up="" and="" graphically="" illustrate="" a="" non-sinusoidal="" periodic="" waveform="" known="" as="" a="" "square="" wave":="" the="" trigonometric="" expansion="" for="" a="" square="" wave="" is="" (??)="4" �sin(????)="" +="" 1="" 3="" sin(3????)="" +="" 1="" 5="" sin(5????)="" +="" .="" .="" .="" �="" ,="" where="" =="" 2????="" a="" square="" wave="" of="" frequency="" f="" is="" built="" up="" by="" summing="" the="" sinusoidal="" waveform="" for="" the="" base="" frequency="" f="" with="" the="" odd="" harmonics="" of="" the="" waveform,="" each="" with="" decreasing="" amplitude="" as="" shown="" above.="" a="" perfect="" square="" wave="" is="" formed="" by="" extending="" the="" trigonometric="" expansion="" to="" an="" infinite="" number="" of="" terms.="" for="" your="" graphical="" demonstration,="" use="" just="" 10="" terms="" and="" show="" the="" build-up="" of="" the="" waveform="" in="" a="" 1×="" 2="" matlab="" subplot.="" in="" the="" left="" plot,="" show="" the="" sinusoids="" as="" they="" are="" added,="" one="" by="" one.="" in="" the="" right="" plot,="" show="" the="" result="" of="" summing="" the="" terms,="" as="" per="" the="" trigonometric="" expansion.="" create="" a="" sequence="" of="" 10="" visualizations="" with="" a="" 500="" ms="" pause="" between="" each.="" show="" the="" waveforms="" over="" two="" cycles="" (i.e.,="" 4π).="" omit="" the="" frequency="" f="" since="" it="" is="" an="" arbitrary="" constant="" (e.g.,="" 1).="" the="" basic="" method="" for="" graphing="" a="" sine="" wave="" is="" shown="" in="" example="" 3="" in="" lecture="" 19.="" with="" just="" the="" 1st="" term,="" the="">
Apr 11, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here