Question

CSCI 251 Lab 6 File I/O Due Data: Nov 22, 2019 Problem Statement Given a text file with experiment data, implement a programSample output: 1 10.999773 2 0.997041 3 0.995374 4 0.99499 5 0.993904 6 0.993343 7 0.993343 8 0.992928 90.991307 10 0.990385

Can this be solved in MATLAB language?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Assuming the input data is given in the file sequentially as numbers. Please find the required MATLAB script as the following:

%=================================================

clc;
clear all;

data = load('input_data.txt'); % Loading input data into data variable
sorted_data = sort(data,'descend'); % Sorting the data
fileOut = fopen('output_data.txt','w');  
fprintf(fileOut,'%f\n',sorted_data); % Writing the data
fclose(fileOut);

%==================================================

Add a comment
Know the answer?
Add Answer to:
Can this be solved in MATLAB language? CSCI 251 Lab 6 File I/O Due Data: Nov...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly...

    Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly hours for all employees are stored in a text file where each line contains the employee name followed by the hours worked for each day of the week. The data is stored as follows (data is continuous in the file but represented in columns below): Kelly Brian Katie Michae Emily Jim John Jane Joe Doe Smith Hart Jones Hu Wright Young Green Hurley Write...

  • The name of the C++ file must be search.cpp Write a program that will read data...

    The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...

  • Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program...

    Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...

  • With Matlab Please Transplant data The data file “transplants.txt” contains the # of transplants performed each...

    With Matlab Please Transplant data The data file “transplants.txt” contains the # of transplants performed each year by different states in the country. Here’s the first few lines of the file: 0, 2015,2014,2013,2012,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000 1,40,401,413,372,422,433,411,428,476,493,493,403,492,454,464,5272,109,711,754,652,735,618,590,601,607,511,498,421,354,376,341,2893,20,123,156,161,155,159,173,158,171,183,185,154,119,122,103,110 . . . Each row is a different state, and each column (starting at column 2)is a different year; the first column is the state #, and the states are always listed 1, 2, 3, ... . The first row of the file is a header...

  • C++ Lab 1. Read in the contents of a text file up to a maximum of...

    C++ Lab 1. Read in the contents of a text file up to a maximum of 1024 words – you create your own input. When reading the file contents, you can discard words that are single characters to avoid symbols, special characters, etc. 2. Sort the words read in ascending order in an array (you are not allowed to use Vectors) using the Selection Sort algorithm implemented in its own function. 3. Search any item input by user in your...

  • C++ Homework Help: The text file that it wants you to download is this: Name: Peter...

    C++ Homework Help: The text file that it wants you to download is this: Name: Peter Parker CSCI-261: 95 CSCI-262: 90.625 CSCI-442: 91.20 Name: Mary Smith CSCI-442: 65.0 CSCI-562: 79.1234 CSCI-580: 70.24 Name: Pat Brown CSCI-562: 95 CSCI-565: 88.0 CSCI-580: 91.20 Name: Linda Williams CSCI-262: 65.0 CSCI-306: 67.719 CSCI-562: 70.200 Name: John Miller CSCI-261: 95.281 CSCI-306: 90.625 CSCI-565: 91.20 Name: Patricia Johnson CSCI-306: 65.012 CSCI-442: 84.76 CSCI-580: 70 Name: Brian Hall CSCI-261: 65.0 CSCI-306: 84.712 CSCI-442: 75.24 Name: Sandra Nelson...

  • Programming language --> Matlab The name of a text file Outputs: (cell) An Nx2 cell array...

    Programming language --> Matlab The name of a text file Outputs: (cell) An Nx2 cell array listing words and their counts in sorted order Function Description: Have you ever seen those fancy word-clouds based on the frequency of word occurrences in some text? Well the first step of making a graphic like that is to figure out how often the words in some text occur, which is exactly what this function will do. You will count the number of occurrences...

  • Using C programming For this project, you have been tasked to read a text file with student grade...

    Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...

  • Write a menu based program implementing the following functions: (0) Write a function called displayMenu that...

    Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...

  • Function / File Read (USING MATLAB) A) create a user-defined function : [maxsample , maxvalue , numsamples]=writetofile(sname,strgth) to do the following: The user-defined function shall: -Accept as t...

    Function / File Read (USING MATLAB) A) create a user-defined function : [maxsample , maxvalue , numsamples]=writetofile(sname,strgth) to do the following: The user-defined function shall: -Accept as the input a provided string for the sample name (sname) and number for strength (strgth) - open a text file named mytensiledata.txt, with permission to read or append the file. - Make sure to capture any error in opening the file - Write sname and strgth to the file - Close the file...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT