A file called tempnums.mat stores for some number of years the average high temp
ID: 3851772 • Letter: A
Question
A file called tempnums.mat stores for some number of years the average high temperatures for each month in each column. The numbers are provided as floating point numbers, but what is desired is integers. Additionally, an application uses this type of data but with each year's data in a row instead of a column. Write a MATLAB script that reads the data from the file tempnums.mat into a matrix, rounds the numbers, and writes the data In the format that the application can use into a file called tempints.mat. Turn in your m-file called HW7_1_LastF.m and the file tempints.mat created by your script using the sample data file provided on eCampus. The file tempnums.mat contains the following: 33.374200000000000 55.464100000000000 29.33410000000000046.526600000000000 35.278400000000000 55.483900000000000 45.53720000000000061.865400000000000 55.62680000000000069.321400000000000 64.098600000000000 77.886800000000000 72.75790000000000082.796600000000000 80.776500000000000 83.898500000000000 70.023400000000000 81.902400000000000 61.348600000000000 78.853100000000000 50.897600000000000 71.021800000000000 42.232300000000000 62.157600000000000 what should be written to tempints.mat is: 33 29 35 46 56 64 73 81 70 61 51 42 55 47 55 62 69 78 83 84 82 79 71 62Explanation / Answer
temperatureData.m
M = dlmread('tempnums.mat');// reads data in file as a matrix
M = round(M);//floating point numbers will be rounded to integers
fileID = fopen('tempints.mat','w');//opens file to write output
fprintf(fileID,'%d %d %d %d %d %d %d %d %d %d %d %d ',M);//output will be written to file as in required format
This program will not run correctly unless input file has rows multiples of 12.
means you have to provide temperature values for every month in a year.
Thankyou
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.