Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with number 2, mat2.txt file is bottom picture Reading a file with file info in a header line 3. There is a file

Need help with number 2, mat2.txt file is bottom picture image text in transcribed
image text in transcribed
Reading a file with file info in a header line 3. There is a file called mat2.txt in our CatCourses files area under the Assignments folder. Download it and save it in the same folder where this Matlab file (Hwe8 02.m) is saved. It may be worth opening that text file to see how it is set out. Note well, however, that the file might have a different number of lines and different number of numbers on each line. Write a Matlab program that does the following: Prompt the user for an input file name and read the user's input to a string variable. Do not assume that the file name will be mat2.txt. (In other words, your script should run fine if the user enters a different file name that has data in the same format.) Open the file name the user has entered for reading and read the first line to see how many lines and columns it has. Use that information to set up a loop to read the rest of the input file into an array. Close the input file * Use a separate loop to print the array to the console in a neat table. Noting that none of the numbers in the input file is larger than 99, choose an output format that results in a neat table with no more than 4 spaces before each number. Do not assume that the input file has a fixed number of rows or columns. Assume that that information is on the first line of the file and read it. Your program may be tested with a different file with a different number of rows and columns. Note that this will require some thought, since the number of columns is can change and your code must adjust for that at runtime. There are several different ways to do this. Among them are creating the format string dynamically as in 2d or using a nested loop to print one column at a time on an output ine

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions