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. C

    MATLAB Matlab basic - how to get around floating point?

    i'm trying to learn MATLAB and as such i stumbled here while looking something up http://www.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html so the questions is how does someone avoid something like e = 1 - 3*(4/3 - 1) (this is example 1 in the webpage above) not...
  2. B

    MATLAB MATLAB-output values matrix

    Hi, I'm trying to write a code for the recursive trapezoidal rule. The code must have the bounds of integration and tolerance. The code is meant to stop when the tolerance between the next and previous value is below 10^-4, given n number of times to sub split the intervals. My progress...
  3. K

    MATLAB Geographically Weighted Regression in MATLAB

    does anyone know sample codes with explanation on computing Geographically Weighted Regression using MATLAB?I am a newbie of MATLAB.
  4. gfd43tg

    MATLAB Learn How to Loop a Matrix in Matlab: Step-by-Step Guide

    Hello, this block of code was given on a previous exam M = [1 3 -2; 7 -5 1]; temp = 0; for k = M temp = temp + k(2) end temp And we are supposed to give the final output of temp. I have no idea how one loops over a matrix, not even elements or anything. What the heck does k = M...
  5. B

    MATLAB [MATLAB] Simple Undamped Forced Vibration Problem

    Hi Folks, I am trying to replicate a solution in Matlab for the following problem ##\displaystyle \ddot x + \frac{k}{m}x = \frac{F_o}{m} \sin w_ot## using 2 first order linear differential equations in Matlab as shown below tspan=[0 4]; y0=[.02;1]; %Initial Conditions for y(1)=x and...
  6. T

    MATLAB Is MATLAB's Implementation of Spherical Harmonics Incorrect?

    Hey guys, This is my first post here, so I will apologize in advance in case I'm posting this in the wrong section. I wrote a very simple function to calculate spherical harmonics in matla, and I used this function during 3 years. Yesterday I found that the function was actually wrong, and...
  7. B

    MATLAB [Matlab] Function Handle-user input

    Hi, My question is in relation to Matlab. I'm curious, is there anyway to employ user inputs for function handles? By this I mean that the user is prompted to enter they're chosen function and the next line of code employs that into a handle. My quick and rough attempt was...
  8. gfd43tg

    MATLAB [Matlab] Order of precedence in computations

    Hello, here is a list of the order of precedence for computations when programming, at least in MATLAB 1. Parentheses (starting with innermost pair) 2. NOT (~) (left to right) 3. Arithmetic operations (left to right) 4. Relational operations (left to right) 5. AND (&) 6. OR (|) 7...
  9. gfd43tg

    MATLAB Mastering Structure Arrays in Matlab: Confusion and Exam Preparation

    Hello, I am preparing for the exam for my Matlab class, and have run into some confusion with Structure arrays. I have a hard time keeping all the concepts straight in my head. I am working on an old exam problem, where this is the structure array, which I will use as an example to demonstrate...
  10. gfd43tg

    MATLAB Matlab Concatenation Help: Resolving B([1 2], [1 3])

    Hello, I am curious why the following concatenation is not working the way I thought it would. B = [0 5 1; 2 4 3] B = 0 5 1 2 4 3 B([1 2], [1 3]) ans = 0 1 2 3 I don't really understand what this command is extracting from the matrix and how it...
  11. gfd43tg

    MATLAB Understanding Matrix Division in Matlab: Solving Linear Systems

    Hello, I am confused about a concept, Suppose I am trying to solve a linear system ##Ax = b## I want to know why is it when I solve for x, the command is x = A\b. Why would it not be x = b\A. One could see that if you divide x on both sides, then b/x = A. Is this not true for the matrix?
  12. T

    MATLAB MATLAB : How to find the line of best fit through a binary image?

    I have found the 2D Fourier transform of a figure and then changed it to a binary image (attached). I want to find the line of best fit through the longest "axis"? of this figure. What would be the simplest way to accomplish this?
  13. M

    MATLAB Multiplications of functions in Matlab

    Hi. When I try to this multiplication: t=[0:0.02:1]; f=exp(-t)*sin(t) Error using * Inner matrix dimensions must agree. in Matlab I take the error above and I can not also plot its graph by plot(x,y). Can somebody help me?
  14. gfd43tg

    MATLAB Loop Analysis in MATLAB: What is the Code Doing?

    Hello, I am trying to decipher loop codes and I am having a lot of difficulty doing so Here is an example code A = 0; while A < 1 for k=1:5 A = A+(-1)^k; end A = A+k; end So I thought the while function does something an infinite amount of times. This is what...
  15. gfd43tg

    MATLAB Understanding the Differences Between & and && Operators in MATLAB

    Hello, I am having some difficulties understanding the difference between the two and when I would want to use one over the other.
  16. mesa

    MATLAB [Matlab] Can't find inputdlg.m file

    I want to look at it and see if there is another option to resize dialog boxes, does anyone know where it is hiding in MatLab R2013b?
  17. dkotschessaa

    MATLAB Matlab - Change parameters of equation while plot displayed

    First note that I am just learning Mat lab, and running a program created by someone else. I have a program which is displaying four differential equations on screen, all with various parameters assigned in the beginning. i.e. alpha=10; beta=0.04; gamma=0.020; etc. For...
  18. M

    MATLAB A matlab warning on solving equations

    Hi, >> d = 'x^2 + 9*x –7 = 0'; >> solve(d) Error using solve>processString (line 354) ' x^2 + 9*x –7 = 0 ' is not a valid expression or equation. Error in solve>getEqns (line 284) eqns = processString(eqns, v, vc); Error in solve (line 160) [eqns,vars,options] =...
  19. M

    MATLAB Matlab Help: EZplot for x^2 – 6x – 12

    d = x^2 –6*x – 12; >> ezplot(d) Error using inlineeval (line 15) Error in inline expression ==> x.^2 –6.*x – 12 Error: The input character is not valid in MATLAB statements or expressions. Error in inline/feval (line 34) INLINE_OUT_ = inlineeval(INLINE_INPUTS_...
  20. M

    MATLAB Creating a Matlab Contour Plot with Iterative Growth - Help Request

    hey pf! i am trying to plot a contour (topographic) graph the following ##f(x,y) = \frac{1}{x^2+y^2} e^{x-(x^2+y^2)^{.5}}## where ##f(x,y) = k## where ##k = .001## and doubles in size for about 8 iterations. my attempt is here: x=-3:0.25:3; y=-3:0.25:3; z=.25:.25:1; [X,Y]=meshgrid(x,y)...
  21. M

    MATLAB [Matlab] Gui help for adding code

    Hi, all there is an example for gui but I can not do. Could somebody help me. I generated a button in gui then I have to add some function on in. Codes are in the picture. Will I add them under callback function? Why can I not determine where I should I add them. To understand it what...
  22. R

    MATLAB [Matlab] Problem in modeling a DAE system using ode15s

    Dear all, I have a coupled system of ode's with an algebraic equation. The equations are as follows, function dy=lorentz(t,y) global Vfc; %fcdata.m % Data file for the hybrid system with parameters values %*************************************** % Physical parameters Rl = 0.024...
  23. ShayanJ

    MATLAB Calculating Bound States of a Particle in a Triangular Well Using MatLab"

    Hi I'm trying to figure out in what energies the bound states of a particle in a symmetric triangular well happen to be, using MatLab(Actually GNU Octave!) At first I non-dimensionalized the associated Schrodinger equation and got: \frac{d^2 \varphi}{dy^2}+[ \varepsilon-v(\pm 2y-1) ]\varphi=0...
  24. M

    MATLAB Exploring MATLAB Toolboxes: Benefits and Installation Guide

    What is a MATLAB toolbox? Can we rebuild them? Can not we use MATLAB effectively if we do not have toolboxes? Are there any pre-installed toolboxes when we install matlab? How can we see if they are installed or not by using or not using matlab. I have never used a toolbox so I do not know...
  25. K

    MATLAB [Matlab] Error running optimization.

    Error running optimization. Inputs must be a scalar and a square matri I am trying to use fminunc using optimtool. But i got the error Error running optimization. Inputs must be a scalar and a square matrix. this is the function i typed in the editor. function F = fun(x) F =...
  26. M

    MATLAB MATLAB Compatibility: Using MATLAB on PC and Mac - A User's Question

    hey pf! i had a question. my university uses MATLAB for computing on a PC. however, i am using a Macbook. do you think the two can sync with each other? i am waiting on purchasing MATLAB until i know for sure both an communicate with each other. thanks all!
  27. B

    MATLAB MATLAB Fourier Synthesis: Create Signal from Spectrum

    Hi I wanted to check how to do a Fourier synthesis to recreate a signal from a frequency spectrum. So I basically have the frequency spectrum so I have the power of the fundamental frequency and the harmonics. Is there a way I can do a synthesis to create a time signal?
  28. H

    MATLAB Composite Simpsons 1/3 matlab code

    hey guys, So I'm working on a MATLAB function that uses simpsons 1/3 rule to find an integral. This is what I have done so far, but I'm not 100% confident.. I seem to get double when I use greater segments. If anyone would be able to have a look at give me some tips that would be very much...
  29. E

    MATLAB Coupled 1st order differential equations in matlab

    Hello everyone I just want to ask if anyone could help me or at least tell me if it is possible to solve the couple equations using matlab I saw ode45 but that is for one equation only Thank uou
  30. E

    MATLAB Need MATLAB Implementation for OFDM Communication Systems in Continuous-Time?

    Hello all, Does it occur that anyone here working on OFDM communication systems? I need a MATLAB implementation of such systems in the continuous time. I will provide the math derivations if requested. Thanks
  31. C

    MATLAB Projectile motion with friction in MATLAB (ODE45)

    I'm working on a little project where I want to plot the motion of a projectile with air resistance. The air resistance can be assumed to be proportional to the velocity squared. F_{f}=-Bv^{2} F_{f,x}=F_{f}\frac{v_{x}}{v}, \ \ F_{f,y}=F_{f}\frac{v_{y}}{v} where B depends on the height...
  32. L

    MATLAB How would you write this equation in MATLAB? (challenging)

    Hello guys, I would like to put this equation into the MATLAB to calculate the global maximum of mutual information function. In order to do that, I notice that I need a gradient of the function which is described as in attached files. I do have the vector for P(x) and P(x|spike). Let's...
  33. B

    MATLAB Computing question 1st year Engineering-MATLAB

    Hi, the question is as follows. I wish to calculate all of the different possible combinations of two vectors in regards to Pythagoras theorem. Not just an element by element operation My code is as follows; opposite=(0:30) adjacent=(0:30) hypotenuse=sqrt(x1.^2+y1.^2) When I use...
  34. P

    MATLAB [Matlab] Replace pixels of an image with theta of Polar Coordinates

    Dear Math and Physics fans You have always been so helpful in the past and I was hoping that I could call on your expertise once again. I want to make a wedge filter in MATLAB so I can determine the orientation of the ellipse of a centered 2D fft. I tried to make an new image where...
  35. ShayanJ

    MATLAB Rutherford scattering using MatLab

    I'm writing a program for simulating the angle distribution of scattered particles from a gold nucleus but I doubt the results. I don't know...But it would be very good if someone check it and give some hints. I also want to ask should I vary both initial speed and impact parameter in one...
  36. S

    MATLAB Measuring the 'purity' of a sine wave using FFT (Matlab)

    I have a range of sine waves I have obtained in an experiment. I want to put a measure on the purity of these sine waves - how well the reproduce a theoretical sine wave. Is there anyway I can analyse the FFT of the sine waves in Matlab and put a measure on the purity of the sine wave...
  37. M

    MATLAB .Should I Upgrade to the Latest Version of Matlab?

    Hello, I have just been wondering that given each year we get two new versions of Matlab, for someone like who uses/used Matlab 2001 (or Matlab 7) I am wondering if there's a great reason to move to the recent versions (Matlab 2014a) even when I use only a selected number of toolboxes. Thanks
  38. V

    MATLAB Minimizing a function in one variable in Matlab

    This problem was originally a multi objective problem but using scalarization it can be transformed to the following: Min: -p'*x + u*x'*V*x subject to 1*x=1 -u is the risk aversion index that I wish to vary from .1 to 100 -V is a (4x4) variance covariance matrix -p is the (4x1) expected...
  39. A

    MATLAB Entering simulink 3D look-up table data from MATLAB

    I have created a contour plot in MATLAB using the following code: >> NP=40; >> [RP TP]=meshgrid(linspace(min(RPM),max(RPM),NP),linspace(min(BMEP),max(BMEP),NP)); >> BSFC_IT=griddata(RPM,BMEP,BSFC,RP,TP); >> NC=12; >> Fig1=figure; >> [CT...
  40. U

    MATLAB Solving equations involving specific elements of matrices in MATLAB?

    So let's say I have 2 matrices A and B. I need to solve 2 eqns involving specific elements of each matrix. e.g. A(1)+B(2)=4; A(1)-B(2)=2. Is there any way to do this? My efforts with Fsolve and solve have failed. Here's what I've done so far: function F=myfun(A,B)...
  41. ShayanJ

    MATLAB Troubleshooting Simple Harmonic Oscillator in MATLAB

    I'm trying to plot the evolution of a simple harmonic oscillator using MATLAB but I'm getting non-sense result and I have no idea what's wrong! Here's my code: clear clc x(1)=0; v(1)=10; h=.001; k=100; m=.1; t=[0:h:10]; n=length(t); for i=2:n F(i-1)=-k*x(i-1)...
  42. E

    MATLAB Can one repeat a matlab script from the beginning?

    For one of my classes, our project is to write a script that simulates the game of craps. I have no problem with the actual game, but one of the criteria is that after the player wins or loses, we are supposed to prompt them to quit or play again (this is where I'm stuck). Is there a command...
  43. E

    MATLAB Matlab : Function handle givin array to cell array of function handles

    Hi. I am currently in a situation where I have a function handle giving as putput an array of doubles. I would like to convert this to a cell array of function handles, each giving a component of the previous array. The original function handle is produced by a built-in MATLAB function, so...
  44. A

    MATLAB Filter command for contour plot MATLAB

    Hi all, I have made a BSFC plot in MATLAB with engine data tested on an eddie current dyno, The code I used for it is: >> NP=40; >> [RP TP]=meshgrid(linspace(min(RPM),max(RPM),NP),linspace(min(Torque),max(Torqu e),NP)); >> BSFC_IT=griddata(RPM,Torque,BSFC,RP,TP); >> NC=12; >>...
  45. J

    Problem loading .wav files in matlab from directory

    Hello participants. Can anyone help me in the code of loading wavs... I am getting some error... Function for the Code is... function [wavs,fs] = load_wavs(directory) % Initialize variables data = 0; fs = 0; % Load the wavs if(nargin < 1), D = dir; else D = dir(directory); end for i=2 ...
  46. Jawz

    Can Vector Loops Simplify Theo Jansen's Linkage Mechanism Equations?

    I'm studying the work of Theo Jansen and want to derive a set of general equations for motion, velocity and acceleration at each point of his linkage mechanism. I've read a general equation can be derived through the use of vector loops but I am having some trouble as my equations have 10...
  47. J

    MATLAB Fixing MATLAB's X-Axis: Troubleshooting Data Subtraction Issues | Learn How Here

    I have a table of data points to be subtracted by another table of data points. I have succeed in subtracting the y values of each data point successfully, but it is the x values of each data point in that I have trouble. m =10; SubDataList=Table[{DataList[[i,All,2]]-BGData[[All,2]]},{i,1,m}]...
  48. E

    MATLAB How can I optimize my MATLAB code for faster Fourier series plot?

    Hi! Here is my m-file for Fourier series plot: clear clc syms n a0=input('Enter coefficient a0: '); an=input('Enter coefficient an: '); bn=input('Enter coefficient bn: '); a=input('Enter lower boundary: '); b=input('Enter upper boundary: '); t=linspace(a,b,10000); sum=0; for n=1:10 %%n could...
  49. Adrian Soo

    Richardson extrapolation matlab error

    Hi everyone, I am trying to differentiate a function by means of Richardson Extrapolation in MATLAB. However, I could not run the program. Here are the outputs and its codes. Could anyone explain to me what is my mistake? The codes are based on "Numerical Methods Using MATLAB by John H. Matthews...
  50. D

    MATLAB Sampling with replacement in Matlab

    I am trying to simulate the probability of rejecting a good batch for a probability of \(0.94\) using the Binomial Probability Law. My two cases are \[ P[k\geq 95] = \sum_{k = 95}^{100}\binom{100}{k}p^k(1 - p)^{100 - k} \] and \[ P[k\geq 98] = \sum_{k = 98}^{100}\binom{100}{k}p^k(1 - p)^{100 -...
Back
Top