Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB For a biomedical experiment, the names and weights of the patients have been stored in a file PatWts.dat (bundled in the .zip file). *For

MATLAB

For a biomedical experiment, the names and weights of the patients have been stored in a file PatWts.dat (bundled in the .zip file).

*For example*, the file may look like this:

Darby George 166.2

Helen Dee 143.5

Giovanni Lupa 192.4

Cat Donovan 215.1

Write a script readpatwts that will first attempt to open the file. If the file open is not successful, an error message should be printed. If it is successful, the script will use fgetl to read the data into strings, one line at a time. Do not assume that the number of lines in the file is known. Use a while loop until the end of the file is reached. Then your script will perform the following additional steps: (1) print for each person the name in the form last,first followed by the weight; (2) calculate and print the average weight. Finally, your script will use fclose to close the file and print whether or not the file was successfully closed.

For example, the result of running the script would look like this:

>> readpatwts

George,Darby 166.2

Dee,Helen 143.5

Lupa,Giovanni 192.4

Donovan,Cat 215.1

The ave weight is 179.30

File close successful

NOTE: I posted this question 2 days ago and it was completely wrong, so please read the instructions carefully. It is asking for fgetl and while loop functions. Also, the file with the information was given as a part of the assignment, you do not need to create the file in the script. Just pretend that there is already a file named PatWts.dat.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions