Question

MatLab Q) Use the file ‘xandypts.dat’ (bundled in the .zip file) whic contains x and y...

MatLab Q) Use the file ‘xandypts.dat’ (bundled in the .zip file) whic contains x and y data points in the following format:

                        x 0 y 1

                        x 1.3 y 2.2

Write a script that will (1) use fopen to open the file and error-check to ensure it was opened; (2) use fscanf to read x and y; (3) compute the sum of x and the sum of y; (4) print out the sum of x and sum of y; (5) use fclose to close the file and print whether or not the file was successfully closed.

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

c4.no ,大w 、, ur.,):

Add a comment
Know the answer?
Add Answer to:
MatLab Q) Use the file ‘xandypts.dat’ (bundled in the .zip file) whic contains x and y...
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
  • A. File I/O using C library functions File I/O in C is achieved using a file...

    A. File I/O using C library functions File I/O in C is achieved using a file pointer to access or modify files. Processing files in C is a four-step process: o Declare a file pointer. o Open the desired file using the pointer. o Read from or write to the file and finally, o Close the file. FILE is a structure defined in <stdio.h>. Files can be opened using the fopen() function. This function takes two arguments, the filename and...

  • Problem 1: Use MATLAB to create a script file and publish a pdf file for the...

    Problem 1: Use MATLAB to create a script file and publish a pdf file for the problem: Given that MX = Y, for the following matrices determine X using both matrix inversion and Gaussian elimination methods 7 -2 4.67 5 7 6.5 -8 13 Y = 13 Display results in short engineering format. Submit the published pdf file. Problem 2: Use MATLAB to create a script file and publish a pdf file for the problem: Given that MX = Y,...

  • Use two files for this lab: your C program file, and a separate text file containing...

    Use two files for this lab: your C program file, and a separate text file containing the integer data values to process. Use a while loop to read one data value each time until all values in the file have been read, and you should design your program so that your while loop can handle a file of any size. You may assume that there are no more than 50 data values in the file. Save each value read from...

  • How would I change the following C code to implement the following functions: CODE: #include <stdio.h>...

    How would I change the following C code to implement the following functions: CODE: #include <stdio.h> #include <stdlib.h> int main(int argc, char * argv[]) { if (argc != 2) printf("Invalid input!\n"); else { FILE * f = fopen (argv[1], "r"); if (f != NULL) { printf("File opened successfully.\n"); char line[256]; while (fgets(line, sizeof(line), f)) { printf("%s", line); } fclose(f); } else { printf("File cannot be opened!"); } } return 0; } QUESTION: Add a function that uses fscanf like this:...

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

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

  • please use matlab 100 Let f(x) for questions 8, 9, 10 8. Make a function file...

    please use matlab 100 Let f(x) for questions 8, 9, 10 8. Make a function file for f(3) = I 100 I f.m function y = f(x) 9. Estimate f'(-5) by making a limit table with 5 rows. >> format long >> clearf . >> h = >> [h; (f(x+h) - f(x))./h]' ans = 0.100000000000000 -4.081632653061220 0.010000000000000 -4.008016032064176 0.001000000000000 -4.000800160032013 0.000100000000000 -4.000080001596017 0.000010000000000 10. Find R4, the Regular Right Sum with 4 rectangles, in order to approximate f(x) dx >>...

  • Write MATLAB code g(x)=x+a*f(x) f(x)=(e^x)+(x^2)-x-4 function f(x) is stored in fogp1.m (c) (1) Create a file...

    Write MATLAB code g(x)=x+a*f(x) f(x)=(e^x)+(x^2)-x-4 function f(x) is stored in fogp1.m (c) (1) Create a file gopgi.m to calculate the function glir, a) (see Preparation, ex. 7c) function [y] =gopg1(x,a) % input: x, a % output: y y= .....; (2) Create a file sucsub1.m and write a program that calculates the solution using the method of successive substitution. Calculate the values of g(x, a) by making multiple calls to the function gopg1(x, a). Take xo = 1.3 as starting value...

  • Use an anonymous function instead of a function file that calculates y(x) = sin(2x)( 4x2 +...

    Use an anonymous function instead of a function file that calculates y(x) = sin(2x)( 4x2 + 3 ). Plot it using fplot, x goes from -8 to 8. Use your function to print out the value of y for x = -1.25 and x = 1.25. Deliverables: Script with anonymous function Plot using fplot Command window output Step by Step Instructions: Copy your calling script from Problem 1 Change the name of the function to be LabFcAnonymous (or something similar)...

  • This is all suppose to be a 1 file code in Matlab For the three problems...

    This is all suppose to be a 1 file code in Matlab For the three problems below create one script, HW8.m and upload it to Blackboard. Each problem must begin with the following lines of code: %Problem # (Insertproblem number) clear (clears workspace) Nothing should write to the screen except for the information requested in each problem. Le use semi-colons throughout your code. Problem 1. An industrial process of water flows through three tanks in succession as illustrated in the...

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