What is Matlab: Definition and 1000 Discussions

MATLAB (an abbreviation of "matrix laboratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages.
Although MATLAB is intended primarily for numeric computing, an optional toolbox uses the MuPAD symbolic engine allowing access to symbolic computing abilities. An additional package, Simulink, adds graphical multi-domain simulation and model-based design for dynamic and embedded systems.
As of 2020, MATLAB has more than 4 million users worldwide. MATLAB users come from various backgrounds of engineering, science, and economics.

View More On Wikipedia.org
  1. E

    Using finite difference method for solving an elliptic PDE with MATLAB

    Homework Statement Given that we the following elliptic problem on a rectangular region: \nabla^2 T=0, \ (x,y)\in \Omega T(0,y)=300, \ T(4,y)=600, \ 0 \leq y \leq 2 \frac{\partial T}{\partial y}(x,0)=0, \frac{\partial T}{\partial y}(x,2) = 0, \ 0\leq x \leq 4 We want to solve this problem...
  2. V

    MATLAB Maximizing the fraction of two integrals using matlab

    EDIT: I left out something of major importance, I want to maximize with respect to a! Good day, I've run into an issue in solving a certain problem with matlab, and I was hoping if anyone could help me out. I am relatively new to matlab, so I don't even know if this is possible, but I...
  3. P

    MATLAB question re interpolation and approximating derivative.

    Hi, I'd sincerely appreciate it if someone were willing to review the few lines of MATLAB code below and indicate why they don't quite yield the expected output. Homework Statement I am asked to generate using MATLAB approximated values of f(x)=cos(x) at nodes x+h,x-h with random errors...
  4. M

    MATLAB MATLAB Script Help - Plotting 2 Functions to Find Intersection

    Attahced is my short MATLAB script, I am basically trying to use iteration to plot 2 sets of 2 functions to see where they intersect, all other information in the script are constants. attached also is the incorrect graph that i get flux = F If = Ifield Any help would be appreciated
  5. M

    MATLAB Need some guidance - Graphing in Matlab

    Need some guidance -- Graphing in Matlab Hello, I am doing a project using Matlab. I need to generate this graph as shown in the attachment. For the gas and liquid superficial velocity, I am able to find the equation but as for the Flow pattern transition boundary equation(the darker lines), I...
  6. M

    MATLAB Irritated by Matlab should I retake the course?

    Hey fellas how are you all doing? This is my first year as an engineering student and so far I am enjoying most of my classes(Math, chem, programming) except for one, my MATLAB class. This class is really a pain in my ***. This is my first time seeing a programming language and I have a grade...
  7. S

    MATLAB How to Resolve a Plotting Error in Matlab?

    HI, i have a set of data that i want to plot with matlab, using an equation. i have all x data points and want to generate y values for each x data point. function y =marko(x) y= (4.11/1.98)*{(1/4*((1-x/L).^2))-(1/4)-(x/L)}; x=(218+data points) from the command window i have...
  8. A

    MATLAB Critical points of system of ODE in MATLAB - Game theory and poker

    Hello there, I hope I'm posting in the right section. I have been doing some work on evolutionary game theory and poker. I will give a brief description of how I got here. I have eight strategies i = 1, 2, \ldots, 8 and the eight proportions of the population playing each strategy is...
  9. S

    Solving Matlab Newton's Method Homework

    Homework Statement So, I've written a program that carries out Newton's method. The root of the equation which I am trying to find is approximately 13.1. This is fine and my program returns the correct value when my initial guess is around this value (up to about x = 50 as my initial guess)...
  10. S

    MATLAB [Matlab] Subscripted assignment dimension mismatch.

    Hi all, I have the following program, but with this error [Subscripted assignment dimension mismatch. Error in test_vlf_spherical (line 62) ep(i,j)=ga(i,j)*ep(i,j)+gb(i,j)*((1./r(i)./dr)*(rph*hr(i,j)-rmh*hr(i-1,j))...] i am trying to solve the problem by using (./) but i...
  11. E

    MATLAB How can I calculate THD using MATLAB?

    Hello, I'm a novice in using MATLAB. I want to calculate THD value from my experimental data using MATLAB. I have 10,001 data points, sampling frequency is 100kHz and fundamental frequency is 50 Hz (I'm not in USA). Below is my code. Could you please check that my code is correct or not ...
  12. P

    MATLAB MATLAB - Calculate distance/perimeter of an object in 2D image

    Hi, I want to find out how thick/big/fat is the object in the image. For example, there is a tree in the image(photograph), I want to use MATLAB to calculate how big the tree trunk is. Problem: Find out the perimeter of trunk as shown in the first picture (named "perimeter.PNG". attached...
  13. O

    MATLAB Mastering Matlab for Bode Plots: Understanding Transfer Functions Easily

    Hello I need to do bode plot.. but i not to sure how to use matlab.. i need this 1 / (a + bs)s num = 1 how to key in the den to get (a + bs)s.. i try different way and i can't get 1/(a+bs)s hope to get help
  14. P

    MATLAB - forming an array of sums?

    Hi, Homework Statement I am asked to evaluate the following sum S=Sigma(n=0 to N) x^n/n! (namely, e^x as n->Inf) for N=10:10:100 and x=10, so that every element S(i) is a partial sum which approximates function e^x with different accuracy. Below is my code, which doesn't work. Homework...
  15. T

    Matlab help. invalid target for assignment trying to solve

    Homework Statement hey there, i'm trying to solve for beta which I tought i'd easily be able to figure out using MATLAB (i'm not the most proficient MATLAB user) but i can't get it to work.. Homework Equations The Attempt at a Solution My code is as follows: clear all...
  16. twoski

    MATLAB Mastering Newton's Method and Graphing in Matlab: A Step-by-Step Tutorial

    Hey guys, I have to make some graphs for an assignment and a friend told me it would be easiest with matlab. I need to make an x(k+1) vs. x(k) graph for Newton's method as well as the Chord method. I also need to make a few charts of the discrete logistic equation. Plotting functions isn't...
  17. I

    Why isn't MATLAB producing graphs for my program?

    Homework Statement Hello there. I ran a MATLAB program and i can't produce any graph. Please help me Homework Equations This are the program L = 1.; T = 1.; maxk = 2500; dt = T/maxk; n=50; dx = L/n; cond = 1/4; b = 2.*cond*dt/(dx*dx); for i= 1:n+1 x(i) = (i-1)*dx; U(i,1) =...
  18. S

    User Defined Functions in MATLAB

    Homework Statement Write a user-defined function that calculates grade point average (GPA) on a scale of 0 to 4, where A = 4, B = 3, C = 3, D = 1, and E = 0. For the function name and arguments use av = GPA(g,h). The input argument g is a vector whose elements are letter grades A, B, C, D...
  19. L

    MATLAB Programming Loops Question

    Homework Statement Write a program that does the following: Prints the four gases on the screen and asks the user to select which gas to find the heat capacity for. Asks the user for a temperature. Asks the user if another temperature is needed (enter yes or no). If the answer is yes...
  20. M

    MATLAB Polymath or Matlab non-linear algebraic solver

    Hello, I am having difficulty inputting a non linear algebraic equation into polymath to solve for reference the equation is x*(100-.5*x)^0.5/(15-x)/(20-.5 * x)^0.5 - 87.824 == 0 and I want to solve for x, but haven't gotten anything. Also I don't know how to program it into matlab...
  21. M

    MATLAB Matlab transfer function problem

    I have a transfer function L(s) = A(s)/B(s) that I call Ls. However, when defining H(s)= L(s)/(1+L(s)) by %% Ls = -70.6s^2 - 2003 s + 3375 -------------------------- s^3 + 119.6 s^2 + 2806 s %% Hs = Ls / (1+Ls) things go wild. The highest...
  22. S

    [MATLAB] complex permittivity for earth ionosphere syntax

    Homework Statement I have these equations: ga = exp(-σ^{R}Δt/ε_{0}*ε^{R}_{r}) Homework Equations σ^{R}=(ε_{0}*ω^{2}_{p}*v)/(ω^{2}+v^{2}) The Attempt at a Solution %ionospheric profile for earth-ionosphere waveguide as coefficients e = 1.602e-19; % electron charge...
  23. M

    MATLAB Plot the equation y=cos(A*x) + i*sin(A*x) in MATLAB

    Hi Everyone, I am a new Matlab User, I am want to plot the equation y=cos(A*x) + i*sin(A*x) where A = 400*pi/340 and want to plot y and vary x from pi:0.1:pi clear all; close all; A = 400*pi/340; x = -180:0,1:180; a=cos(A*x); b=i*sin(A*x); i= imag(b); hold on; grid...
  24. S

    MATLAB Probability at Party function.

    Homework Statement So, you're asked to write a function that computes the probability of two people at a party having the same birthday. The probability function itself is P(n) = 0, n = 1 P(n) = 1 - (capital pi from k = 1 to k = n - 1)(1 - k/365), 2 <=n <= 365 P(n) = 1, n >= 366 The...
  25. R

    MATLAB Skin effect derivation and plotting in Matlab

    This is driving me crazy. The derivation of the current distribution in a long cylindrical wire is extremely straightforward, giving J(r) = J(a) \frac{J_0(k r)}{J_0(k a)} where J is the current density, a is the radius of the wire, and k is the complex wave vector, which in a metal (with...
  26. N

    MATLAB Plotting cosine in matlab looks really funky

    I have to plot a bunch of cosine waves and then add them up but my problem is that each indiviudal wave looks really weird when I plot and not like a cos wave. The program runs and plots the final result but I'm not sure how accurate it is because when I plot each individual cos wave I know it...
  27. P

    MATLAB Create B-Spline curve using MATLAB

    I need a MATLAB expert to guide me on how to create a b-spline curve using MATLAB Software. I understand the B-spline basis function calculations for zeroth and first degree but I have no idea on how to calculate for the 2nd degree. I need a favor on that part. I am currently working on my...
  28. S

    Using Tic Toc in MATLAB for Calculating Sum with Loops and Vectorised Commands

    Homework Statement Calculate the time taken to compute sum of 1/k^3 from 1 -> 1000 using both loops and vectorised commands using tic toc. Homework Equations The Attempt at a Solution tic n = 1e3; % number of terms in the sum s = 1...
  29. S

    MATLAB Matlab - matrix with blank space

    r=zeros(1,6); r(1,2:4)=2; r(1,5)= - rfor the above program, I want the output as r= 0 2 2 2 - 0 how to do this in matlab? please help
  30. P

    MATLAB Solving an Argument in MATLAB with Linprog

    Dear All Firstly, thank you for looking at my post. I am so close to a solution to a problem that has been given me a massive headache. I am also very stupid and was wondring if one of smart guys could take a look at my problem and see if you might be able to help. I am trying to...
  31. S

    MATLAB Nested if statements in MATLAB

    Just started a new college module and we'll be using MATLAB quite a bit. I was wondering, can you nest if statements in MATLAB like in C#? Would code such as this work in MATLAB? if (condition 1) if (sub condition 1) Code elseif (sub condition 2) Code elseif (condition...
  32. B

    MATLAB Need help plotting Fourier series in matlab

    Hi all my first post as I need to seek help! I have just learned some simple Fourier series stuff and would like to be able to plot my answers in matlab. Assuming this is correct I was wondering if someone would be able to walk me through plotting this equation in Matlab...
  33. T

    How can I improve my GE program using MATLAB?

    Homework Statement I am writing a GE program and i think i have that correct. I have a matrix and i am trying to find the correct answer. I am not sure where i am going wrong. Homework Equations The Attempt at a Solution %GE with no pivoting function x=ge_nopivot(A,b)...
  34. T

    Matlab help. Using Newton Raphson

    Homework Statement Two forces P and Q are applied at the end of a screw eye in order to remove the post. Homework Equations The two equations that were found are 1.) Q*sin(30)-P*sin(θ)=0 2.) Q*cos(30)+P*cos(θ)-800=0 The Attempt at a Solution I combined the 2 equations by first...
  35. B

    MATLAB Doing a phase-space portrait in matlab

    So I have this system of equations: \binom{x_{n+1}}{y_{n+1}}=\begin{pmatrix}e^{r} & 0 \\ 0 & e^{-r} \end{pmatrix}\begin{pmatrix}cos(\phi+I_{n}) & -sin(\phi+I_{n}) \\ sin(\phi+I_{n}) & cos(\phi+I_{n}) \end{pmatrix}\begin{pmatrix}x_{n}\\ y_{n} \end{pmatrix} where I_{n}=x_{n}^2+y_{n}^2...
  36. T

    Writing Matlab program for Newton Raphson

    Homework Statement Two forces P and Q are applied at the end of a screw eye in order to remove the post. 1.)variations (plots) of P and Q versus (theta) for a given value. R=800 N 2.) for what value of theta we obtain P=Q? Homework Equations...
  37. A

    MATLAB Excel date column export into Matlab

    Hi everybody, I need assistance. I have excel file that conntains a date column and another column. I wish to plot the date on x-axis and the second column on y axis. I wrote the MATLAB code below. This is my code. data=xlsread('DataTest','Sheet1'); q=data(:,2); time=data(:,1); Error...
  38. P

    MATLAB Histogram coloured by different hues in matlab

    Dear Physics fans, Are we all okay? I hope so. I was wondering if you could help me please? I am banging my head against a wall in MATLAB and I think what I need to do should be very easy. I have a histogram of intensities and I could like to colour then starting off at black and...
  39. N

    MATLAB Understanding Positive Feedback in MATLAB

    Hi All, Suppose I have the following system: A = 1 / (S + 1) (open loop) B = S / (2S + 1) (feedback path) I know that the positive feedback closed loop system will thus be: A / (1 - AB), and entering this manually in MATLAB (as well as doing it by hand), I get: 2 s^2 + 3 s...
  40. S

    MATLAB Solving MatLab Misunderstanding: Element-by-Element and Point-wise

    I'm current learning MatLab before i start my second year of engineering and i don't really understand a fundamental aspect of it. My problem is the use of the period "." and when it is deemed to be necessary. I've looked up what this operator does and found definitions such as Element by...
  41. M

    Finding the sum of multiples of 3 and 5 below 1000 (Matlab)

    Homework Statement Project Euler Problem 1. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Hello, there I do understand what a multiple is, and...
  42. H

    MATLAB Cavity simulation on matlab with spatially dependent phase

    Hello there, I have been searching for MATLAB simulations that analyze optical cavities and there are some useful codes. Yet, I haven't found codes that analyze what happens to cavit transverse modes if spatially dependent phase is introduced between mirrors Does anybody know if there...
  43. dexterdev

    MATLAB How to find covariance matrix of 3 or more vectors in matlab?

    Hi all, I know how to find covariance of 2 vectors and variance too. If covariance matrix is to be found of 3 vectors x,y and z, then then the cov matrix is given by cov_matrix(x,y,z) =[var(x) cov(x,y) cov(x,z); cov(x,y) var(y) cov(y,z); cov(x,z) cov(y,z) var(z) ]; Is this...
  44. M

    MATLAB Matlab - area values into raster data

    I'm trying to transform area values into raster data. I have areas, defined as circles (location of center + length of radius). Each area has a designated value between 0 and 2. I used Matlab's command area to plot the areas and also to designate the value that goes with each area. Now I want...
  45. D

    MATLAB A simple symbolic expression in Matlab

    I tried to check x²-1 = (x+1)(x--1) So I did the following: Matlab returns 0. Any suggestions? :) (Matlab beginner by the way)
  46. B

    Code for matlab convolution by FFT

    Homework Statement You have two functions in Matlab (represented as column vectors). Compute their convolution using the fast Fourier transform. Homework Equations The Attempt at a Solution I am having trouble finding a book with this topic. I would like to know where the...
  47. M

    MATLAB Geographical points + great circle = ellipse? (Matlab)

    I'm doing this in Matlab but it's not restricted to any particular software. I have a bunch of geographical points (x,y coordinates for each) and I want to take all the points that are 50 km or closer to the reference point. I took the great-circle equation to convert geographical longitude...
  48. I

    MATLAB How Can You Handle Unassigned Outputs in Simulink's Embedded MATLAB Function?

    Hello everyone! In Simulink , I use the Embedded MATLAB Function function out = fcn(meas) if meas>10 out = 4; elseif meas<=0 out=2; end And I get this message: Output argument 'out' is not assigned on some execution paths. I would like the variable 'out' to change its...
  49. B

    MATLAB Fixing Matlab GUI Resize Problem: Repositioning and Full Screen Issues

    I have been trying the following to reposition my GUI (within the OpeningFcn): h=get(handles.figure1,'Position'); set(0,'Units','normalized') S = get(0,'screensize'); width = h(3); height=h(4); x = (S(3) - width)/2; y = (S(4) - height)/2...
  50. B

    MATLAB What could be causing unexpected positioning of a GUI in Matlab?

    I have been trying the following to reposition my GUI (within the OpeningFcn): h=get(handles.figure1,'Position'); set(0,'Units','normalized') S = get(0,'screensize'); width = h(3); height=h(4); x = (S(3) - width)/2; y = (S(4) - height)/2...
Back
Top