Question

in MATLAB

Create a file “parts_inv.dat” that stores on each line (1) a part number, (2) cost, and (3) quantity in inven- tory, in the f

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

clc, clear, close all Name main.m parts_inv.dat main. mx fileID = fopen(parts_inv.dat, r); format Spec = %d %f %f; $for

parts_inv.dat x 1 123 5.99 52 2 124 6.23 67 3 125 8.00 83

Program Code to Copy:

clc,clear,close all

fileID = fopen('parts_inv.dat','r');
formatSpec = '%d %f %f'; % format of one line of data
sizeA = [3 Inf]; %
inventoryData = fscanf(fileID,formatSpec,sizeA);
fclose(fileID);

totalDollarPerPart = inventoryData(2,:) .* inventoryData(3,:); % cost*quantity
totalDollar = sum(totalDollarPerPart)

------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,

IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~

Add a comment
Know the answer?
Add Answer to:
in MATLAB Create a file “parts_inv.dat” that stores on each line (1) a part number, (2)...
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
  • java Part 1 Create a NetBeans project that asks for a file name. The file should...

    java Part 1 Create a NetBeans project that asks for a file name. The file should contain an unknown quantity of double numeric values with each number on its own line. There should be no empty lines. Open the file and read the numbers. Print the sum, average, and the count of the numbers. Be sure to label the outputs very clearly. Read the file values as Strings and use Double.parseDouble() to convert them. Part 2 Create a NetBeans project...

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

  • Java Language Create file fports with the first line as a hostname that needs to be...

    Java Language Create file fports with the first line as a hostname that needs to be scanned for certain ports to be opened on it (the values shown are examples... you need to select your own values): host name 80 22 443 445 Write a java program to accomplish the following: Open file fports Read the hostname to be scanned and store it in variable hostname Read the ports into array of integers ports Create array status (of boolean type)...

  • Part 1 The purpose of this part of the assignment is to give you practice in...

    Part 1 The purpose of this part of the assignment is to give you practice in creating a class. You will develop a program that creates a class for a book. The main program will simply test this class. The class will have the following data members: A string for the name of the author A string for the book title A long integer for the ISBN The class will have the following member functions (details about each one are...

  • how to do the fun1.m function? 1.1 Part 1 First, learn how to create a function...

    how to do the fun1.m function? 1.1 Part 1 First, learn how to create a function in MATLAB. Given the function U(T) = 0.12 – 2 sin(1) Create a MATLAB function that you can call from the main *.m file. Use the MATLAB Help by typing help function to learn about it. There are more than one way to create a function in MATLAB. For this lab, use the most basic one, i.e., by creating a function file that contains...

  • DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the...

    DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the following calculations. Your script will use the functions you create. Label all graphs appropriately. For this project, do not have your homemade functions fprintf anything, instead have all your fprintf commands within your script. Attach your published script file along with .m files for your functions. Exercise 1. A fundamental iterative method for finding the roots of equations of one-variable is known as Newton's...

  • A Les Mills BODYPUMP instructor has a list of the weight plates for her classes and...

    A Les Mills BODYPUMP instructor has a list of the weight plates for her classes and saved in a file. Each weight plate was stored with the weight (kg), color, and quantity. Write a program that reads in the data (a list of weight plates) from a file, and sort the plates by weight, and write the ordered list to the output file. Assume the input file plates.txt has the format of weight (double), color (one word string), followed by...

  • ** Language Used : Python ** PART 2 : Create a list of unique words This...

    ** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...

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

  • Part 1: Read 2 numbers from the user. One small number and one big number for...

    Part 1: Read 2 numbers from the user. One small number and one big number for the range. Use this in a for loop with range (for x in range(small, big)) Add all the numbers in this range and store in a variable called total. Print total. Part 2: Make a list of colors called COLORS. Have at least 10 colors. Read one color from the user in a variable called color. Now use a for loop, and see if...

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