Hello, The first part of this problem was to create a basic temperature converte
ID: 3784904 • Letter: H
Question
Hello,
The first part of this problem was to create a basic temperature converter in MATLAB. I completed that part, but I am unsure how to execute these problems. I am VERY new to MATLAB so please show them in very basic beginner code and include in depth, detailed comments so that I can understand the processes. Please be sure to look at the example output as shown below. Also, please specify where the created text file is located.
Thank you
2. Writing a Random Temperature File (33 points) Write a function that writes a series of random Fahrenheit temperatures and their correspond- ing Celsius temperatures to a tab-delimited file. Use 32 to 212 as your temperature range. From the user, obtain the following: The number of temperatures to randomly generate. The name of the output file. A sample run is included below (you must follow the format provided below): Please enter the name of your file: Example txt Please enter the number of iterations: 100 Example txt Fahrenheit Celsius 111.29 44.05 78.71 25.95 137.66 58.70 88.17 31.20 etc... 3. Reading a Random Temperature File (34 points) Write a function that reads a file produced by Problem 2. Focusing only on the Celsius temperatures in the file, calculate and display to screen the following: Mean or Average Minimum MaximumExplanation / Answer
Program :
function [] = FtoC()
fileName = input('please enter the name of your file : ');
numIteration = input('Please enter the number of iterations : ');
%%numIteration = str2num(numIteration);
fahreheitTemp = (212-32).*rand(numIteration,1)+32;
celsiusTemp = (fahreheitTemp(:,1)-32)*5/9;
fid = fopen(fileName, 'wt' );
fprintf(fid,'Fahrenheit Celsius');
for i=1:numIteration
fprintf(fid,' %f %f',fahreheitTemp(i,1),celsiusTemp(i,1));
end
end
Result: Example.txt
Fahrenheit Celsius
55.383118 12.990621
134.388259 56.882366
116.490315 46.939064
34.142373 1.190207
92.682076 33.712264
61.192815 16.218231
174.971217 79.428454
88.018708 31.121504
127.135964 52.853314
61.816771 16.564873
140.356749 60.198194
79.334831 26.297128
149.734238 65.407910
156.058611 68.921450
166.667287 74.815159
113.097488 45.054160
47.087848 8.382138
73.215854 22.897697
196.400725 91.333736
59.428043 15.237802
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.