Using The fprintf Command
The fprintf command allows us to send send the data from our table t the command window and organize it. We are able t create sentences that give more meaning to the information.There are, also, other useful commands, such as the \n command, that we may use within the fprintf command to make adjustments to the format. \n causes the next line below to be used immediately after. This is why each sentence contains it's own row.
Saving Work And M-Script
Within the command window, we are able to save and load work using the save and load commands.
We begin to use the M-Script file capability. This capability is the preferred method for doing work on MATLAB. To begin work on the M-Script, we simply choose "new script" on the top left corner of the program and the program opens up a tab in the middle of the program. In this tabe, we are able to write commands similar to that of the command window. The only difference is that once enter is pressed, the command is not initiated. Like programming, the commands are pre-written and when the user wants to implement the commands, he/she just simply presses the "run" tab and this tells MATLAB to run the commands in the command window. We are also able to save any commands that were written in an m-file. This allows the user to save all the work done. Also, like in standard programming practices, notes can be inputted using the percent key. This allows for other users to understand what was done and to better organize the work.
Problem Solving Using M-Script
We take a look at equations for velocity and acceleration. All we have to do is plug in the value for time to get the speed and acceleration at that very moment.
Using the same problem on the white board, we create a set of values for time and input it in the equations for velocity and acceleration. We create a table and used the fprintf command to create well documented answer.
Next, we take a look at the definition of power and its relationship to velocity and force. Using this relationship, we are able to solve for the acceleration at two different velocities.
We take the power problem to MATLAB. This time, we start to look at the input command. With the input command, we are able to create a program that will calculate the acceleration of a moving object with fixed values for power and mass. The input allows another user to run the program ind input a value, in this case, for velocity. Once the user input the value, the program calculates the acceleration.
Summary:
We discussed some of the way to display messages on MATLAB using the fprintf command and utilizing these messages to display important information in a legible manner. We also go over some of the techniques for saving and documenting any work on MATLAB. M-Scripts provide a convenient way to keep track and save any work done on MATLAB. We do some simple calculations to get the hang of M-Script and finish off by utilizing the input command. This command allows a user to input different values in a program without messing with the actual program.







No comments:
Post a Comment