Difference between revisions of "MATLAB"
(22 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | {{Software| | + | {{Software |
− | name=MATLAB| | + | |name=MATLAB |
− | byline=Matrix Laboratory Software| | + | |byline=Matrix Laboratory Software |
− | image=[[File:Matlab Logo.png|200px]]| | + | |image=[[File:Matlab Logo.png|200px]] |
− | caption=| | + | |caption= |
− | version= | + | |version=R2014a on UNIX<br>R2016a (or newer) for download |
− | dlocation=On Unix<br>[ | + | |vdate=2/11/2014 for R2014a |
− | cost=Free on UNIX| | + | |dlocation=On Unix<br>[https://software.duke.edu/node/130 OIT] to install. |
− | manufacturer=MathWorks| | + | |cost=Free on UNIX |
− | webpage=http://www.mathworks.com| | + | |manufacturer=MathWorks |
− | label_color=| | + | |webpage=http://www.mathworks.com |
+ | |label_color= | ||
+ | |value_color= | ||
+ | |update=8/18/2017 | ||
+ | |}} | ||
'''MATLAB''' is a MATrix LABoratory program that can be used to load, process, generate, present, and analyze numerical data. | '''MATLAB''' is a MATrix LABoratory program that can be used to load, process, generate, present, and analyze numerical data. | ||
+ | ==Installation== | ||
+ | *Information on installing, activating, and using MATLAB on a personal computer can be found [https://knowledge.oit.duke.edu/?p=784 here]. | ||
==FAQ== | ==FAQ== | ||
Line 24: | Line 30: | ||
=== How do you even get IN to MATLAB? I have no idea... === | === How do you even get IN to MATLAB? I have no idea... === | ||
− | *After logging in to an OIT machine (or using [[ | + | *After logging in to an OIT machine (or using [[MobaXterm]] to get there from a PC , or using [[X11R6]] on a Mac to log in) just type <code>matlab &</code> at the command prompt. |
=== How do you type MATLAB code in these pages, and how do you make it pretty? === | === How do you type MATLAB code in these pages, and how do you make it pretty? === | ||
Line 36: | Line 42: | ||
c1 = data(:,1); c2 = data(:,2); c3 = data(:,3); c4 = data(:,4); | c1 = data(:,1); c2 = data(:,2); c3 = data(:,3); c4 = data(:,4); | ||
plot(time, c1, 'b-', time, c2, 'g--', time, c3, 'r-.', time, c4, 'c:') | plot(time, c1, 'b-', time, c2, 'g--', time, c3, 'r-.', time, c4, 'c:') | ||
− | legend('0', '1', '2', '3', | + | legend('0', '1', '2', '3', 'location', 'best') |
xlabel('Time (s)'); ylabel('Voltage (V)'); | xlabel('Time (s)'); ylabel('Voltage (V)'); | ||
</source> | </source> | ||
Line 48: | Line 54: | ||
c1 = data(:,1); c2 = data(:,2); c3 = data(:,3); c4 = data(:,4); | c1 = data(:,1); c2 = data(:,2); c3 = data(:,3); c4 = data(:,4); | ||
plot(time, c1, 'b-', time, c2, 'g--', time, c3, 'r-.', time, c4, 'c:') | plot(time, c1, 'b-', time, c2, 'g--', time, c3, 'r-.', time, c4, 'c:') | ||
− | legend('0', '1', '2', '3', | + | legend('0', '1', '2', '3', 'location', 'best') |
xlabel('Time (s)'); ylabel('Voltage (V)'); | xlabel('Time (s)'); ylabel('Voltage (V)'); | ||
</source> | </source> | ||
::See the page linked above for other languages that are parsed. | ::See the page linked above for other languages that are parsed. | ||
+ | |||
=== How do I change colors and fonts? === | === How do I change colors and fonts? === | ||
In the '''File''' menu, pick '''Preferences''' and, in that window, look three different places: | In the '''File''' menu, pick '''Preferences''' and, in that window, look three different places: | ||
Line 68: | Line 75: | ||
===How do I define a function in a text file?=== | ===How do I define a function in a text file?=== | ||
*See the [[MATLAB:User-defined_Function|User-defined Function]] page in the MATLAB name space. | *See the [[MATLAB:User-defined_Function|User-defined Function]] page in the MATLAB name space. | ||
+ | |||
+ | === How do I run MATLAB without the GUI?=== | ||
+ | When attempting to use MATLAB on a Unix machine when you're not at Duke, it's often easier to refrain from opening the GUI (which can be too slow). Here are some steps around that. | ||
+ | # SSH into a Unix machine | ||
+ | # Navigate to directory with MATLAB Script | ||
+ | # Ensure MATLAB Script has the command 'exit' on its last line | ||
+ | # type 'which matlab' into the command prompt, which should output something like /usr/bin/matlab | ||
+ | # Assuming the output is /usr/bin/matlab, enter '/usr/bin/matlab -nosplash -nodisplay -nodesktop < fileToRun.m > outputFile.txt' into command prompt | ||
+ | # Open outputFile.txt by typing 'cat outputFile.txt' into the command prompt. This will allow you to see the text output of the MATLAB file. | ||
+ | |||
+ | Note: If you want to view images, type the "print -dpng 'figureToView.png';" command after each plot in your MATLAB script. A .png file will be saved in the same directory after compilation. | ||
== Questions == | == Questions == | ||
Line 73: | Line 91: | ||
== External Links == | == External Links == | ||
− | * The MathWorks: [http://www.mathworks.com/ Main Page], [http://www.mathworks.com/support/ Support Site], [http://www.mathworks.com/academia | + | * The MathWorks: [http://www.mathworks.com/ Main Page], [http://www.mathworks.com/support/ Support Site], [http://www.mathworks.com/academia Academia Center], [http://www.mathworks.com/academia/classroom-resources/ Classroom Resources] (includes topic- and department-specific subpages) |
− | + | ||
* Paper on [http://www.mathworks.com/company/newsletters/edu_digest/2007/aug/computational.html Introducing Computational Methods to First-Year Students with Diverse Skills and Interests], Michael Gustafson, August, 2007 | * Paper on [http://www.mathworks.com/company/newsletters/edu_digest/2007/aug/computational.html Introducing Computational Methods to First-Year Students with Diverse Skills and Interests], Michael Gustafson, August, 2007 | ||
Line 81: | Line 99: | ||
[[Category:Software]] | [[Category:Software]] | ||
− | [[Category:ECE | + | [[Category:ECE 382]] |
− | [[Category:EGR | + | [[Category:EGR 103]] |
− | [[Category:EGR | + | [[Category:EGR 224]][[Category:ME 344]] |
+ | |||
+ | [[Category:Semester Update]] |
Revision as of 13:34, 27 September 2017
Version | R2014a on UNIX R2016a (or newer) for download |
---|---|
Vers. Date | 2/11/2014 for R2014a |
Download | On Unix OIT to install. |
Cost | Free on UNIX |
Manufacturer | MathWorks |
Web Page | http://www.mathworks.com |
Pundit Updated | 8/18/2017 |
MATLAB is a MATrix LABoratory program that can be used to load, process, generate, present, and analyze numerical data.
Contents
- 1 Installation
- 2 FAQ
- 2.1 MATLAB gives me the splash screen, then just sits there...
- 2.2 MATLAB on Unix just sits there - I think I created an infinite loop! Or I am running a program that will take a significant fraction of forever to complete...
- 2.3 MATLAB on Windows just sits there - I think I created an infinite loop! Or I am running a program that will take a significant fraction of forever to complete...
- 2.4 How do you even get IN to MATLAB? I have no idea...
- 2.5 How do you type MATLAB code in these pages, and how do you make it pretty?
- 2.6 How do I change colors and fonts?
- 2.7 How do logical masks work?
- 2.8 What do the line number mean on the CB-68LP card?
- 2.9 How can I use inline functions?
- 2.10 How can I use anonymous functions?
- 2.11 How do I define a function in a text file?
- 2.12 How do I run MATLAB without the GUI?
- 3 Questions
- 4 External Links
- 5 References
Installation
- Information on installing, activating, and using MATLAB on a personal computer can be found here.
FAQ
MATLAB gives me the splash screen, then just sits there...
- Go to a terminal window and type "ps -u NETID" with your NET ID. There should be a process called "matlab". Get the number off it, then type "kill -KILL NUMBER" (the adverb really is "-KILL"). Then, go to your root directory, change into the .matlab directory and remove the contents with "rm -ir *" (make SURE you are in the .matlab directory). Go back to where you were and start matlab again.
MATLAB on Unix just sits there - I think I created an infinite loop! Or I am running a program that will take a significant fraction of forever to complete...
- Go to a terminal window and type "ps -u NETID" with your NET ID. There should be a process called "matlab". Get the number off it, then type "kill -KILL NUMBER"
MATLAB on Windows just sits there - I think I created an infinite loop! Or I am running a program that will take a significant fraction of forever to complete...
- Hit CTRL-C to break out of Matlab.
How do you even get IN to MATLAB? I have no idea...
- After logging in to an OIT machine (or using MobaXterm to get there from a PC , or using X11R6 on a Mac to log in) just type
matlab &
at the command prompt.
How do you type MATLAB code in these pages, and how do you make it pretty?
- The SyntaxHighlighting extension is installed on this wiki, so all you have to do is use the appropriate source and lang tags. The code:
<source lang="matlab"> %% Post-processing % take data from AI [data, time] = getdata(AI); %% plot data c1 = data(:,1); c2 = data(:,2); c3 = data(:,3); c4 = data(:,4); plot(time, c1, 'b-', time, c2, 'g--', time, c3, 'r-.', time, c4, 'c:') legend('0', '1', '2', '3', 'location', 'best') xlabel('Time (s)'); ylabel('Voltage (V)'); </source>
- produces
%% Post-processing
% take data from AI
[data, time] = getdata(AI);
%% plot data
c1 = data(:,1); c2 = data(:,2); c3 = data(:,3); c4 = data(:,4);
plot(time, c1, 'b-', time, c2, 'g--', time, c3, 'r-.', time, c4, 'c:')
legend('0', '1', '2', '3', 'location', 'best')
xlabel('Time (s)'); ylabel('Voltage (V)');
- See the page linked above for other languages that are parsed.
How do I change colors and fonts?
In the File menu, pick Preferences and, in that window, look three different places:
- The Fonts section allows you to change fonts. Make sure to choose a monospaced font.
- The Colors section allows you to change most of the colors. Pay careful attention to the sample color block in this window to make sure you can read all the different colors of text.
- The Editor/Debugger section has a Display subsection - this is where you can control the color of the current line (the default is not to alter it) as well as the color of a highlighted section (i.e. a segment of code under a %% comment)
How do logical masks work?
- See the Logical Masks page in the MATLAB name space.
What do the line number mean on the CB-68LP card?
- See the CB-68LP_Pinout page in the MATLAB name space.
How can I use inline functions?
- See the Inline Function page in the MATLAB name space.
How can I use anonymous functions?
- See the Anonymous Function page in the MATLAB name space.
How do I define a function in a text file?
- See the User-defined Function page in the MATLAB name space.
How do I run MATLAB without the GUI?
When attempting to use MATLAB on a Unix machine when you're not at Duke, it's often easier to refrain from opening the GUI (which can be too slow). Here are some steps around that.
- SSH into a Unix machine
- Navigate to directory with MATLAB Script
- Ensure MATLAB Script has the command 'exit' on its last line
- type 'which matlab' into the command prompt, which should output something like /usr/bin/matlab
- Assuming the output is /usr/bin/matlab, enter '/usr/bin/matlab -nosplash -nodisplay -nodesktop < fileToRun.m > outputFile.txt' into command prompt
- Open outputFile.txt by typing 'cat outputFile.txt' into the command prompt. This will allow you to see the text output of the MATLAB file.
Note: If you want to view images, type the "print -dpng 'figureToView.png';" command after each plot in your MATLAB script. A .png file will be saved in the same directory after compilation.
Questions
Post your questions by editing the discussion page of this article. Edit the page, then scroll to the bottom and add a question by putting in the characters *{{Q}}, followed by your question and finally your signature (with four tildes, i.e. ~~~~). Using the {{Q}} will automatically put the page in the category of pages with questions - other editors hoping to help out can then go to that category page to see where the questions are. See the page for Template:Q for details and examples.
External Links
- The MathWorks: Main Page, Support Site, Academia Center, Classroom Resources (includes topic- and department-specific subpages)
- Paper on Introducing Computational Methods to First-Year Students with Diverse Skills and Interests, Michael Gustafson, August, 2007