Question

Help on writing a MATLAB code. Let's say i am given a .txt file and in...

Help on writing a MATLAB code.

Let's say i am given a .txt file and in that text file there are 26 rows that represent individual students grades and then 7 columns that represent specific homework assignments.

We want to ask the user to select a specific homework assignment and output the mean and standard deviation for that assignment.

Then we want to ask the user to select an individual student and output the mean and standard deviation for that student's grades.

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

solution.m

fileID = fopen('a.txt','r');
A = fscanf(fileID,'%f');
grades = vec2mat(A,7);
assignment = input('Enter homework assignment number from 1 to 7 :');
if assignment >=1 && assignment <=7
m = mean(grades(:,assignment));
sigma = std(grades(:,assignment));
fprintf('mean = %f ',m);
fprintf('std = %f ',sigma);
else
disp('please enter assigment b/w 1to 7');
end
student = input('Enter homework student number from 1 to 26 :');

if student >=1 && student <=26
m = mean(grades(student,:));
sigma = std(grades(student,:));
fprintf('mean = %f ',m);
fprintf('std = %f ',sigma);
else
disp('please enter student number b/w 1to 26');
end

a.txt

6 1 1 10 8 2 2
8 5 7 7 4 5 10
8 6 1 8 3 10 9
6 7 6 3 9 6 5
8 8 8 6 10 1 8
7 7 3 9 7 1 5
2 8 5 5 3 9 9
6 4 6 10 1 5 4
4 6 1 1 9 4 1
1 2 5 4 6 8 6
2 1 7 6 10 4 10
2 10 3 1 1 6 2
7 3 9 8 6 8 5
5 6 10 6 3 9 8
7 10 9 6 9 4 1
3 2 6 9 2 7 10
1 2 3 9 5 10 8
6 4 8 8 4 1 6
3 10 3 4 9 6 2
10 4 10 5 7 5 5
10 3 7 8 3 4 6
4 2 7 2 4 3 10
1 4 2 2 2 8 9
7 4 1 3 7 10 10
9 2 3 6 6 2 7
10 5 9 10 2 8 5

Add a comment
Know the answer?
Add Answer to:
Help on writing a MATLAB code. Let's say i am given a .txt file and in...
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
  • There is a file called mat2.txt in our files area under the Assignments folder. Download it...

    There is a file called mat2.txt in our files area under the Assignments folder. Download it and save it in the same folder where this Matlab file (HW08_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...

  • Python question When reading and writing into a file. Say i want to read in input...

    Python question When reading and writing into a file. Say i want to read in input using a file called input.txt and then do something. Then i want to output the results to an additional file called output.txt. i have seen ouput.out or results.out used and not .txt. What is the difference? When would you use .out and not .txt? thank you

  • I need help writing this C code. Here is the description: Let's say we have a...

    I need help writing this C code. Here is the description: Let's say we have a program called smart typing which does two things: The first letter of a word is always input manually by a keystroke. When a sequence of n letters has been typed: c1c2...cn and the set of words in the dictionary that start with that sequence also have c1c2...cnc then the smart typing displays c automatically. we would like to know,  for each word in the dictionary,...

  • I am having trouble trying to output my file Lab13.txt. It will say that everything is...

    I am having trouble trying to output my file Lab13.txt. It will say that everything is correct but won't output what is in the file. Please Help Write a program that will input data from the file Lab13.txt(downloadable file); a name, telephone number, and email address. Store the data in a simple local array to the main module, then sort the array by the names. You should have several functions that pass data by reference. Hint: make your array large...

  • (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that...

    (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...

  • 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...

  • Matlab question Task 2 Download the ENG1060studentmarks.txt file from the Moodle. The file contains the following...

    Matlab question Task 2 Download the ENG1060studentmarks.txt file from the Moodle. The file contains the following information: 1. Column 1: Student ID 2. Column 2--11: Lab marks (/10) worth 2% each (20% total of final grade) 3. Column 12: Assignment mark (/10) worth 10% of the final grade 4. Column 13: Exam mark (100) worth 70% of the final grade a) Write a function that accepts a student's laboratory, assignment and exam marks as inputs to determine the final mark...

  • Python Help Please! This is a problem that I have been stuck on.I am only suppose...

    Python Help Please! This is a problem that I have been stuck on.I am only suppose to use the basic python coding principles, including for loops, if statements, elif statements, lists, counters, functions, nested statements, .read, .write, while, local variables or global variables, etc. Thank you! I am using python 3.4.1. ***( The bottom photo is a continuation of the first one)**** Problem statement For this program, you are to design and implement text search engine, similar to the one...

  • Create a program (Lab9_Act1_Write.py) that will read in data from the keyboard and store it in...

    Create a program (Lab9_Act1_Write.py) that will read in data from the keyboard and store it in a file. Your program should prompt the user for the name of the file to use and then request values be entered until the user is done. This data should be written to two files: a text file, user_file_name.txt and a comma separated value file, user_file_name.csv. To help you with decision making, we suggest that you ask the user to input data representing students’...

  • Please help with this code For the following problem write a Matlab® script file with clear...

    Please help with this code For the following problem write a Matlab® script file with clear commentary for each line of code. Your script should: Load the data in the problem as a text file. Calculate the statistics using Matlab  functions. Solicit input from the user of the reading (for example, 137 degrees as stated in the problem). In another word, the reading should not be fixed in the script and has to be entered and saved from the command window...

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