What is the solution to Chapter 9 Question 11E from the textbook \"MATLAB: A Pra
ID: 3926706 • Letter: W
Question
What is the solution to Chapter 9 Question 11E from the textbook "MATLAB: A Practical Introduction To Programming And Problem Solving Third Edition". The question reads," Create a file which stores on each line a letter, a space, and a real number. For example, it might look like this: e 5.4 f 3.3 c 2.2 Write a script that uses textscan to read from this file. It will print the sum of the numbers in the file. The script should error-check the file open and close, and print error messages as neccessary.
Explanation / Answer
try
fid = fopen('data.txt', 'r');
res = textscan(fid,'%d');
disp(sum(res))
catch ex
disp(' Cannot open file')
disp(ex)
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.