[SOLVED] 代写 matlab graph CivEng 2E03 Fall 2019 Matlab Assignment 1 Matlab Review Materials

30 $

File Name: 代写_matlab_graph_CivEng_2E03_Fall_2019__Matlab_Assignment_1_Matlab_Review_Materials.zip
File Size: 810.12 KB

SKU: 4103492700 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


CivEng 2E03 Fall 2019Matlab Assignment 1 Matlab Review Materials
This document outlines some functions that will be helpful when you are working on this assignment.
Subplots
In MATLAB, a figure is essentially a window containing a plot or plots or other graphical items. We have created figures previously simply by using the plot function. In these cases, all of our graphs have been on the sample plot within the figure. MATLAB has the capability to create multiple plots within a figure using the subplot function:
The subplot function has the following syntax:
subplotrow,column,number
plotx,y
Where row tells MATLAB how many plots you want in the vertical direction, column tells how many in the horizontal direction, and number tells MATLAB which plot to work with. The subplot number goes from left to right, top to bottom. For example, to create a figure with 4 plots that are placed 2 by 2, the code is:

subplot2,2,1
plotx1,y1
subplot2,2,2
plotx2,y2
subplot2,2,3
plotx3,y3
subplot2,2,4
plotx4,y4
Displaying to the Command Window using fprintf
Until this point we usually have not worried about how to display output to the command window. However, it is often beneficial to be able to nicely format your output. The fprintf function in MATLAB is key for creating formatted output. To simply output a string of text, the syntax is as follows:
fprintfText to output.n
The n is necessary to tell MATLAB to go onto the next line. Without it, fprintf will continue to
print in the same place. Try comparing the following:
fprintfText to output.
fprintfLine 2
to
fprintfText to output.n
fprintfLine 2n
Remember that MATLAB always encloses strings in single quotes . fprintf is also great for nicely outputting values that were calculated within the code. This is achieved using a format string, and telling MATLAB which variables to output.
fprintfformat stringn, variables
For example, if you want to define a string of text outside of fprintf, and then display it:
mystring2E03 is the best course.;
fprintfs n,mystring
MATLAB interprets the s as a string, and replaces its value with the string. This can be done with numbers and other values as well. For example:

thisyear2019
fprintfThe Current Year is d n,thisyear
thisyear2019;
thisday14;
thismonthNovember;
fprintfThe current date is s d, d.n,thismonth, thisday, thisyear
d is an integer value. To format a number with a certain number of decimal places, MATLAB uses f:
x2.017859320;
fprintfThe value of x to 2 decimal places is: .2fn,x
Where .2f tells MATLAB to display two .2 decimals.
For a more comprehensive review of fprintf, take a look at the online MATLAB documentation, and test out the functions capabilities.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 matlab graph CivEng 2E03 Fall 2019 Matlab Assignment 1 Matlab Review Materials
30 $