Difference between revisions of "MATLAB"

From PrattWiki
Jump to navigation Jump to search
(Installation)
(Installation)
 
(4 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
|image=[[File:Matlab Logo.png|200px]]
 
|image=[[File:Matlab Logo.png|200px]]
 
|caption=
 
|caption=
|version=R2019a on UNIX<br>R2019a (or newer) for download
+
|version=R2024a on UNIX<br>R2024a (or newer) for download
|vdate=3/8/2019 for R2019a on UNIX
+
|vdate=1/1/2024 for R2024a on UNIX
 
|dlocation=On Unix<br>[https://software.duke.edu/node/130 OIT] to install.
 
|dlocation=On Unix<br>[https://software.duke.edu/node/130 OIT] to install.
|cost=Free on UNIX
+
|cost=Free for Duke community members
 
|manufacturer=MathWorks
 
|manufacturer=MathWorks
 
|webpage=http://www.mathworks.com
 
|webpage=http://www.mathworks.com
 
|label_color=
 
|label_color=
 
|value_color=
 
|value_color=
|update=8/26/2019
+
|update=6/15/2024
 
|}}  
 
|}}  
  
 
'''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==
 
==Installation==
Information on installing, activating, and using MATLAB on a personal computer can be found [https://oit.duke.edu/help/articles/kb0023255 here] at Duke OIT's page.  If this link goes to a search page instead, search for "Install MATLAB." Note - the instructions for installing MATLAB are a little off.  Here's the version as of August 2021:
+
Information on installing, activating, and using MATLAB on a personal computer can be found at [https://oit.duke.edu/help/articles/kb0023255 https://oit.duke.edu/help/articles/kb0023255].  If this link goes to a search page instead, search for "Install MATLAB." Note - the instructions for installing MATLAB are a little off.  Here's the version as of June 2024:
 
* Log in to your MathWorks account and add your licenses as noted by the OIT page.
 
* Log in to your MathWorks account and add your licenses as noted by the OIT page.
Once that is done, you will have a list called "My Software" associated with your license. To the right of the "Use" column there should be a download icon.  Click that.
+
* Click on the "Get Started" button.
* On the next screen, you will have the option to download various MATLAB versions.  Pick the newest one (R2021a as of this writing).
+
* From the next page, click on the "Install MATLAB" button.
* Pick the correct operating system and follow the instructions, using defaults if possible, '''until you get to the "PRODUCTS" tab'''
+
* On the next screen, you will have the option to download various MATLAB versions.  Pick the newest one (R2024a as of this writing). Choose if you are installing or updating and then verify that the operating system is correct.  If so, click the Download button.
* In the PRODUCTS tab, be sure to select at least:
+
* Launch the installer.
 +
* For PRODUCTS tab, be sure to select at least:
 
** MATLAB, Simulink
 
** MATLAB, Simulink
*** For ECE 280: Audio Toolbox, Control System Toolbox, DSP System Toolbox, Image Processing Toolbox, Signal Processing Toolbox
+
*** For Signals and Systems (ECE 280): Audio Toolbox, Control System Toolbox, DSP System Toolbox, Image Processing Toolbox, Signal Processing Toolbox
 
*** For Mechatronics (EGR 224) or Controls (ECE 382 / MEMS 244): Control System Toolbox, Signal Processing Toolbox
 
*** For Mechatronics (EGR 224) or Controls (ECE 382 / MEMS 244): Control System Toolbox, Signal Processing Toolbox
 
*** The Statistics and Symbolic Math toolboxes are also very popular
 
*** The Statistics and Symbolic Math toolboxes are also very popular
* The installation process will take some time; the install above is about 12 Gb total!
+
* The installation process will take some time; the install above is about 8-12 Gb total!
 +
=== Adding Toolboxes ===
 +
If you forgot a toolbox and need to add it:
 +
* Start MATLAB
 +
* Click the arrow under Add-Ons and select Get Add-Ons
 +
* Search for the Add-On you need
 +
* Install the Add-On; MATLAB will make sure you have any pre-requisite Add-Ons and will add them if needed
  
 
==FAQ==
 
==FAQ==
Line 109: Line 116:
  
 
[[Category:Software]]
 
[[Category:Software]]
 +
[[Category:ECE 280]]
 
[[Category:ECE 382]]
 
[[Category:ECE 382]]
 
[[Category:EGR 103]]
 
[[Category:EGR 103]]

Latest revision as of 16:21, 19 June 2024

MATLAB
Matrix Laboratory Software
Matlab Logo.png
Version R2024a on UNIX
R2024a (or newer) for download
Vers. Date 1/1/2024 for R2024a on UNIX
Download On Unix
OIT to install.
Cost Free for Duke community members
Manufacturer MathWorks
Web Page http://www.mathworks.com
Pundit Updated 6/15/2024


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 at https://oit.duke.edu/help/articles/kb0023255. If this link goes to a search page instead, search for "Install MATLAB." Note - the instructions for installing MATLAB are a little off. Here's the version as of June 2024:

  • Log in to your MathWorks account and add your licenses as noted by the OIT page.
  • Click on the "Get Started" button.
  • From the next page, click on the "Install MATLAB" button.
  • On the next screen, you will have the option to download various MATLAB versions. Pick the newest one (R2024a as of this writing). Choose if you are installing or updating and then verify that the operating system is correct. If so, click the Download button.
  • Launch the installer.
  • For PRODUCTS tab, be sure to select at least:
    • MATLAB, Simulink
      • For Signals and Systems (ECE 280): Audio Toolbox, Control System Toolbox, DSP System Toolbox, Image Processing Toolbox, Signal Processing Toolbox
      • For Mechatronics (EGR 224) or Controls (ECE 382 / MEMS 244): Control System Toolbox, Signal Processing Toolbox
      • The Statistics and Symbolic Math toolboxes are also very popular
  • The installation process will take some time; the install above is about 8-12 Gb total!

Adding Toolboxes

If you forgot a toolbox and need to add it:

  • Start MATLAB
  • Click the arrow under Add-Ons and select Get Add-Ons
  • Search for the Add-On you need
  • Install the Add-On; MATLAB will make sure you have any pre-requisite Add-Ons and will add them if needed

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:

  1. The Fonts section allows you to change fonts. Make sure to choose a monospaced font.
  2. 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.
  3. 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?

What do the line number mean on the CB-68LP card?

How can I use inline functions?

How can I use anonymous functions?

How do I define a function in a text file?

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.

  1. SSH into a Unix machine
  2. Navigate to directory with MATLAB Script
  3. Ensure MATLAB Script has the command 'exit' on its last line
  4. type 'which matlab' into the command prompt, which should output something like /usr/bin/matlab
  5. Assuming the output is /usr/bin/matlab, enter '/usr/bin/matlab -nosplash -nodisplay -nodesktop < fileToRun.m > outputFile.txt' into command prompt
  6. 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

References