Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a matlab function that will work for ALL test cases for the following description. Function Name: arr2text Inputs: (double) A non-empty array of positive
Write a matlab function that will work for ALL test cases for the following description.
Function Name: arr2text Inputs: (double) A non-empty array of positive integers (char) A filename Outputs: none File Outputs: A formatted table containing the array values Function Description: Sometimes it is important to be able to share formatted data but you don't have the luxury of being able to send an Excel sheet, Word document or any other type of rich-text document. In these cases, a plain-of' text file will have to suffice. However, your tables can still look good! In this problem, you will be given an array of data that you need to convert into a formatted table and write that table to a text file. Here's the specification for the formatting: Each column of the table should be the width of the largest number in that column. Each row should be delimited by -'s Each column should be delimited by |'s The intersection of the row and column delimiters should be +'s All numbers should be left-aligned in their cell and padded with spaces The formatted array should be written to a file specified by the second input. Here is an example: array = [45, 78923, 3; ... 8923, 9, 8] file Name = 'example.txt' After the function runs, a file named example.txt should be created containing the following: Notes: The file should not have an extra new line at the end. You can run the solution function to see the files created if you need more examples. When running the solution function, use a different filename than the one used in your codeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started