Reference no: EM13713074
Answer the following questions and also justify your answers with appropriate examples
Question- 1 Write a function named 'read_line' which has one input parameter ('specs') and one output parameter ('ret_line'). Your function should do the following:
Question- 2 Suppose 'specs' is a struct with 4 fields: {file_dir, file_name, nlines, my_line}. Use if?end or if?elseif?end statements to check that:
Part a- 'specs'isindeedastruct.
Part b- Thefourfieldsaboveallexist.
Part c- Thefields'file_dir','file_name'are(non?empty)strings
Question-3 You should use the 'error' function to indicate an error if your checks above fail.
Question-4 Now supposes you have a directory whose name is stored in 'specs.file_dir' which contains a file whose name is stored in 'specs.file_name'.
You should suppose that you have a simple text file which contains text (NOT numeric data).
Question-5 Your function should open the file (hint: use fopen), and read 'specs.nlines' number of lines (rows) from the file into a cell array 'C'. Each element of C should have one line from your file.
You can suppose that there are no errors in the parameter 'specs.nlines', that is, it can't exceed the number of lines in your file.
Question-6 Suppose 'specs.my_line' specifies some line number. The output parameter 'ret_line' should be set to this line (you should return a string).
Question-7 Verify that your code works by saving some text into a file (created in notepad / textedit) and saving the file with extension '.txt'. You should attach the file (call it 'test.txt') with your code.
Could you show me how to write a proper code for this problem and how to complete it. Thanks
Prepare a general set of instructions
: Prepare a general set of instructions that will allow us to change any displayed value (from 0 to 9) to any desired value (from 0 to 9) in the least number of steps.
|
Implement a class student
: Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply a suitable constructor and methods getName( ), addQuiz(int score), getTotalScore( ), and getAverageScore ( ).
|
Write a flowchart to solve any linear equation
: Write a flowchart to solve any linear equation ax+b=0 -
|
Find how much heat per cycle does the engine absorb
: How much work does this engine do each cycle.How much heat per cycle does this engine absorb at the hot reservoir?
|
Write a function named read_line
: supposes you have a directory whose name is stored in 'specs.file_dir' which contains a file whose name is stored in 'specs.file_name'.
|
What should be the banking angle of the curve
: What should be the banking angle of the curve so that the force of the pavement on the tires of the car is in the normal direction? Answer in units of degrees.
|
What is the average friction on the ball
: a 200 g plastic ball is at rest on a frictionless incline 0.658 m above the surface of a table. The ball then rolls down the incline and across the table coming to rest after a distance of 2.45 m.
|
Determine how far apart are mars and phobos
: Mars has a mass of about 6.77×1023kg, and its moon Phobos has a mass of about 9.6×1015kg. If the magnitude of the gravitational force between the two bodies is 4.58×1015N.
|
Write an unambiguous grammar
: Write an unambiguous grammar for the given languages- You have to prepare unambiguous grammar for the above languages. Please help! I am stuck on this question
|