What is the solution to Chapter 9 Question 11E from the text

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.

Solution

try
   fid = fopen(\'data.txt\', \'r\');
   res = textscan(fid,\'%d\');
   disp(sum(res))
catch ex
   disp(\'\ Cannot open file\')
   disp(ex)
end

What is the solution to Chapter 9 Question 11E from the textbook \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site