Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Advanced File Input and output:
Where 'format' involves the conversion characters much like those used in the fprintf function. For illustration, to read the file 'subjexp.dat' just shown, we can do the following (again, for ease, omitting the error-check of fopen & fclose):
>> fid = fopen('subjexp.dat');
>> subjdata = textscan(fid,'%f %c');
>> fclose(fid)
The format string '%f %c' identifies that on each line there is a double value followed by the space followed by the character. This generates a 1 × 2 cell array variable known as the subjdata. The initial element in this cell array is a column vector of doubles (the initial column from the file); the next element is a column vector of characters (the next column from the file), as shown here:
>> subjdata
subjdata =
[5x1 double] [5x1 char]
>> subjdata{1}
ans =
5.3000
2.2000
3.3000
4.4000
1.1000
>> subjdata{2}
a
b
To refer to separate values from the vector, it is essential to index into the cell array by using curly braces and then index into the vector by using the parentheses.
Index vector: The index vector is then used as the indices for original vector. To get grades vector in ascending order, the indices used would be grades (2), grades (5), and
Example of Functions which return values: Calling this function prints the circumference, since there is no way to store the value, hence, it can be used in following computat
Areacirc function: The areacirc function can be called from the Command Window as shown here, or from a script. Here is a script which will prompt the user for the radius of o
Example of Mode When no value appears more often than any other, the smallest value in the vector will be the mode of the vector. >> shortx = [2 5 1 4]; >> mode(shortx
Indexing: The Indexing is an alternate to sort a vector. With indexing, the vector is left in its original order. An index vector is used to point values in the original vecto
Sequential Search: A sequential search is completed by looping through the vector element-by-element starting from the beginning, looking for the key. Usually the index of the
Example of Core objects: The one core graphics object is a line that is also what the plot function produces. Here is an illustration of generating a line object, altering som
Execution of persistent variables: The functions can also be called from the script or from the Command Window, as shown here. For illustration, the functions are called first
Example of Nested functions: For illustration, the function below computes and returns the volume of a cube. Three arguments are then passed to it, for the width and length of
Illustration of Nested loops: Running the script shows the output: >> printstars ***** ***** ***** The variable rows identifies the number of rows to print, and
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd