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 Problems using integral function in Matlab

    Hi there! i have this function handle: integrando= @(x,landa,t) 1-exp(-((1/(landa*t))*((exp(-landa*x)/x)+((x-x0).*(1+landa*x0)-x0)*(exp(-landa*x0)/(x0^2))))); which as you can see using fplot(@(x) integrando(x,3,0.00063),[0 1.1225]) its value is constant (actually 1, and then starts...
  2. A

    MATLAB How to add trendline to semilog plot in matlab

    Hi, I have x and y vectors, x=[ 90868 68151 45434 34076 27261 13631 6816 3408 2273 1948 1705 1137 853 683 569 455 342 274 228 190]; y=[ 3680 3723 3800 3866 3920 4103 4250 4320 4340 4344 4350 4364 4373 4379 4384 4393 4398 4402 4405 4407]; I need to plot semilogx in MATLAB and add trendline and...
  3. K

    MATLAB Plotting a Function in MATLAB Using QUAD

    hello.can anyone help me to plot this function in matlab Q=quad(@(omeg)myfun(omeg,x,t),-20,20).im not sure if this is correct.my m file function goes like that function y= @myfun(omeg,x,t) y=besselj(1,omeg.*x).*cos(omeg.*t).*omeg; thanks in advance
  4. N

    Need guide to design FIR bandpass filter using calculation or MATLAB

    Homework Statement hey there.. I really hope u guys can help me extracting the important element from the question below; A signal is sampled at the sampling rate of 10kHz. The signal has useful signal content between 1kHz and 2.4kHz, and distortion of not more than 1dB is required for...
  5. P

    Creating a Model of a Tube/Ear Canal in MATLAB

    Homework Statement The context of this question is that it is the first question on a post grad paper in transducers and sound reinforcement. We've been looking at using electrical circuits to model acoustical and mechanical systems, and also using two-port analysis. I need to create a...
  6. M

    MATLAB MATLAB help: Interpolating an array of data to create a function

    Hi, As the title suggests, I have a 2D array of data. Essentially, I solved a DE using MATLAB and it gave me the array of x against t. I want MATLAB to create a function for me by interpolation so I can use it again (to solve another different set of DEs). I've been stuck on this for a while...
  7. Y

    MATLAB Help with Matlab Problem: Maclaurin Series

    Help in Matlab problem! Hello guys, I really need your help in this question, it's a maclaurin series and I don't know how to do it in matlab. here is the question : http://sphotos-a.ak.fbcdn.net/hphotos-ak-snc6/734976_2640341944275_792908261_n.jpg I hope that you can help me ASAP :(
  8. S

    MATLAB code for Aldous-Broder algorithm from spanning trees of a graph

    Homework Statement Let G = (V,E) be a graph with vertices V and edge set E. Aldous-Broder algorithm: Input: G = (V,E) Output: T = (V, W), where W is a subset of E such that T is a spanning tree of G. Let W be the empty set. Add edges to W in the following manner: starting at any...
  9. A

    MATLAB Plotting with different y-axes range in Matlab

    Good Day Everybody, Please assist me on these problems 1. I wish to put six plots on the same plot using matlab. The details of each plot are stated below PLOT 1 x axis range 0:1 y axis range 0:1 PLOT 2 x axis range 0:1 y axis range 0:1 PLOT 3 x axis range 0:1 y axis range...
  10. A

    MATLAB Combining Plots with Different Y-Axis Ranges in Matlab?

    Good Day Everybody, Please assist me on these problems 1. I wish to put six plots on the same plot using matlab. The details of each plot are stated below PLOT 1 x axis range 0:1 y axis range 0:1 PLOT 2 x axis range 0:1 y axis range 0:1 PLOT 3 x axis range 0:1 y axis range...
  11. marellasunny

    MATLAB Spruce budworm diff.eq,parameter variation using matlab functions

    I have come across a MATLAB code for solving the spruce budworm differential equation.But,I would like to solve the same differential equation for a range of parameters(r=0:5,q=0:10).I am having problems trying to define the array of matrices for each loop.Please look at the code below:% This...
  12. H

    MATLAB Problems with the latest version of Matlab

    Has anyone found that their MATLAB programs are now giving nonsensical results in te latest version of matlab? I wrote a program which worked very well in the 2011 version of MATLAB but now in the 2012 version of MATLAB it still sort of runs but nor yields nonsensical results. I can show...
  13. X

    Plotting DTFT of Finite Sum in MATLAB

    Homework Statement x[n] = Ʃ ck * δ(n-k), from k = -N to N. Plot the DTFT as a function of the number of terms N. This is a finite sum. Homework Equations The equation for the DTFT of a signal, which is Ʃ x[n] * e-j*2∏*∅*n, from n = -∞ to +∞ The Attempt at a Solution I have...
  14. thekey

    MATLAB Please I need a Help with matlab code (Controlling the LEGO NXT Using MatLab)

    Hi Controlling the LEGO NXT Using MatLab What are my mistakes in this code ??! COM_CloseNXT all clc clear handle = COM_OpenNXT(); COM_SetDefaultNXT(handle); COM_CloseNXT(handle); NXT_GetBatteryLevel(handle); COM_CloseNXT(handle); COM_CloseNXT all clc clear...
  15. E

    MATLAB Use finite difference method to solve for eigenvalue E in Matlab

    Use finite difference method to solve for eigenvalue E from the following second order ODE: - y'' + (x2/4) y = E y I discretize the equation so that it becomes yi-1 - [2 + h2(x2i/4)] yi + yi+1 = - E h2 yi where xi = i*h, and h is the distance between any two adjacent mesh points. This is my...
  16. M

    MATLAB Calculate Relative intensity noise using laser Rate equations matlab

    Hello Everybody, I'm trying to plot the frequency spectrum of RIN using Matlab. I've the following code function p=rateblock tau_s = 3e-9; N0 = 1e24; A =1e-12; P0 = 1/(A*tau_s); TSPAN = 0:1e-2:10.23;; Y0 =[0 0]; [T,Y] = ODE45(@rate_equation,TSPAN,Y0); subplot(2,1,1)...
  17. J

    MATLAB Graph Piecewise Functions in MATLAB?

    Hey guys. I need to graph a piecewise function in MATLAB and I don't know how to do it. On top of that, it is also in radians: f(θ) = (80/∏2) θ, -∏/2 ≤ θ ≤ ∏/2 (80/∏) - (80/∏2) θ, ∏/2 ≤ θ ≤ 3∏/2 How do I graph it in MATLAB? And other than that, is there a way in MATLAB that I can take...
  18. S

    Quick question (hopefully) on Matlab transfer functions

    Homework Statement I'm reading through the help files and came across this example: s = tf('s'); H = s/(s^2 + 2*s +10); I understand that when using a rational expression it must be specified, s= tf('s'); I also understand that the rational expression is entered through H=s/(s^2 +...
  19. G

    MATLAB DSOLVE: Solving 2nd Order ODEs with Initial Conditions

    Homework Statement I am using MATLAB Symbolic Tool Box "Dsolve" to solve 2nd order, linear, ordinary, non-homogenous differential equation with initial conditions. Homework Equations Equation of motion with base excitation (vibration: single degree of freedom system) The Attempt at...
  20. A

    MATLAB How to properly use accumarray in MATLAB with sorted indices and weights?

    accumarray documentation Is anyone proficient in the use of accumarray? I supply two vectors of same length, indices L,weights W, L positive integers as required. I sort the indices to ascending.Then, the result of accumarray is not equal to unique(L).How could this be? Code for illustration: i...
  21. T

    MATLAB How to Set Axis Limits for an Added Graph in MATLAB?

    Hi, I am plotting 3 graphs in MATLAB using plotyy as [ax h1 h2] = plotyy(x1,Ftemp,x2,Fsnow); hold(ax(2), 'on'); h3 = plot(ax(2),x1,Fprec); I am thus adding the third graph to the right hand y-axis. I then set the limits and tickmarks for the right hand y-axis as set(ax(2), 'xlim'...
  22. S

    Matlab and finite element

    Homework Statement The problem picture is attached(file 1),its a beam subjected to horizonatal ditributed load 2. Relevant examples the MATLAB solution for rectangular shape with vertical load on the upper right corner is like follow, i try to modify it according to the new picture...
  23. K

    How Can MATLAB Help in Plotting the Electric Field of a Charged Wire?

    Homework Statement A straight wire of electric charge truncate to length L has a linear charge density of ρ= 8 C/m. Using a computational approach calculate the electric field due to the truncated line at any arbitrary point in space. Consider L = 1 m, assume line lies along y-axis with...
  24. S

    MATLAB How Do You Solve Coupled ODEs Using MATLAB's ode45?

    Help me with coupled ode45 equations in MATLAB please I have no idea to turn these into MATLAB code, and here is the porblem: y(1)' = y(2) y(2)' = - (r+re)/(L+le)*y(2) - y(1)/c*(l+le) y(3)' = y(4) y(4)' = -c*y(4).^2 /m+L*y(2).^2/(2*m) where re = ro+Rpr*z+Lpr*z' le = Lo+Lpr*z the rest...
  25. E

    Matlab - Weird answer with all zeroes

    I programmed a function that outputted this weird answer that looks like: ans = 1.0e+147 * Columns 1 through 16 0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 Columns...
  26. E

    MATLAB Writing mathematical equations in MATLAB

    Hello, I have the attached paper, and I want to write equations 4, 5 and the equation in the first line after equation 5 in MATLAB. I did it as following: Np=24; L=19; TapsL=[1 19 20]; S=length(TapsL); Index=zeros(S,1);%Tap Locations c=zeros(L+1,1); cHatMP=zeros(L+1,1)...
  27. I

    Matlab Programming(Need help with the last couple of details)

    Homework Statement Okay, so I need some help with this Matlab program. I never learned Matlab, so I'm trying to do it as best as I can. The question is: Calculate the 2nd and 3rd degree Taylor polynomials for the function f(x)=ln(1+x) about the point a=0 Plot these polynomials and the...
  28. Q

    MATLAB Fit data with a curve in MATLAB

    Hi friends. I want to fit my x datas and y datas with a function in the most exact way.my data is: x=[0.3 0.5 0.7 0.9 1 1.3 1.4 1.5 2 3 5 7 9 10 30 50 70 90 100]; y=[13.4347 8.3372 6.3107 5.27 4.93 4.28 4.14 4.0199 3.6349 3.3178 3.1282 3.0691 3.0432 3.0354 3.0043 3.0016 3.0008 3.0005...
  29. M

    MATLAB Calculating similarity between users using matlab

    Hi all, I am having database of 963 users . Records of two users are uid gender occupation age 1 F student 23 2 M teacher 30 Now i need to calculate the similarity of each user with every other as sim(ui,uj)=0.8*sim(age) +...
  30. J

    MATLAB Troubleshooting MATLAB Simulink Circuits for Sinusoidal Wave

    Hey guys. I am trying to simulate some circuits in MATLAB's Simulink, and I always get some weird graph which is not sinusoidal at all. I wanted to know if anyone could tell me which block am I missing if I want to get a good sinusoidal wave. Here are the pictures of the circuit and the...
  31. Q

    MATLAB Problem in triplequad in matlab

    Hi friends I want to get 3variable integral from a function which is in terms of x,y,z,m,a but I know that a=0.01 and m=3 and want to integrate over x ,y,z >> triplequad((4 .*((-2.* a + m).^2 .*(4 .*a + m) +4 .*a.^2 .*(2.*(2.*a - m).* cos(z) + cos(y) .*(4.* a - 2.* m + 4 .*a.* cos(z) - m...
  32. A

    MATLAB [Matlab] Plotting two functions of the same variable against each other

    I need to make two plots of volume as a function of time vs pressure as a function of time. When plotted the graph will have an enclosed area. I am having trouble on how to have MATLAB plot these two functions against each other. My experience with MATLAB is having a function defined in a...
  33. E

    Why am I only getting one output when I run my Matlab function with 2+ outputs?

    I'm having trouble getting two outputs. Here's a simple example: function [a b] = test2() a = 2; b = 5; When I run the code, I only get the output of a = 2: >>test2 ans = 2 How can I get b outted as well?
  34. M

    MATLAB Plotting a potential function in MATLAB

    Hi all, I would like to be able to plot this function in MATLAB \mathcal{V} (\phi_{1}, \phi_{2}) = m^2(\phi_{1}^2 + \phi_{2}^2) + \lambda( \phi_{1}^2 + \phi_{2}^2)^2Where \phi_{1,2} , m^2 , \lambda \in \mathbb{R} and \lambda > 0 I am aware that the cases m^2 > 0 and m^2 < 0 yield two...
  35. N

    MATLAB Matlab recursion (error in book?)

    This is what my book gives for recursion of fibonacci sequence (matlab coding). function res = fib(n) if n == 1; res = 0; elseif n == 2 res = 1; else res = fib(n-1) + fib(n-2); end Am I mistaken or this doesn't work for fib(3)? Keep in mind I am still learning about...
  36. B

    [MATLAB] Making code faster/more efficient

    A is a sparse matrix. B is a vector. I have the following code: for j=1:N B=A*B; end; This part of the code is inside a function which gets called about 160000 times. I ran the Profiler and this part is the bottleneck. How can I make it more efficient?
  37. J

    MATLAB Functions close to zero in MATLAB

    Hi all, I need to find where a collection of curves are all approximately equal to zero (given some tolerance level) and was wondering if anyone could help me? I'm running the following script in MATLAB: dF2=0.001; dG2=0.001; initF2=0.522; initG2=-0.603; K=zeros(2); etaspan=[0...
  38. P

    MATLAB .Getting Started with MATLAB for Astrophysics Projects

    Hello, This is my first semester as a graduate student in astrophysics. I have a project and I should use MATLAB. Unfortunately, I don’t know how to use the software. Can someone please recommend any tutorials, books, links, ebooks, … Thanks a lot
  39. Q

    MATLAB Matlab help User defined function

    I made a user-defined function for Height. function Ht=Height(t,V,Theta); Ht=V*t*sin(Theta)-4.9*t.^2; end V is initial velocity, and i kept on getting input "V" is undefined. Can someone help me please!
  40. Q

    Matlab help User defined function

    I tried to make a user-defined function. function Ht=Height(t,V,Theta); Ht=V*t*sin(Theta)-4.9*t.^2; but then i kept on getting Input argument "V" is undefined... can someone help me please
  41. marellasunny

    MATLAB Output of ode45 for System of Differential Equations

    My book explains the command x(:,1) as "x,all rows,first column". Q.How does the output of ode45 for a system of differential equations look like? But,when I solve a system of 2 first order differential equations(w.r.t time),I take x as a "column vector". [x1 x2] So,if I wanted to plot x(1)...
  42. Q

    MATLAB Solving a MATLAB Problem with 3 Variable Integration

    dear friends i want to do set of operation in MATLAB but i have a problem: first of all, i want to take 3variable integration from f which is function of x,y,z,m,a but i want to integrate only over x,y,z after that for a special "a" forexample a=0.01 i want to solve the equation.i mean...
  43. W

    MATLAB Estimating the variance of eigenvalues of sample covariance matrices in Matlab

    I am trying to investigate the statistical variance of the eigenvalues of sample covariance matrices using Matlab. To clarify, each sample covariance matrix, \hat{\mathbb{R}}_{nn}, is constructed from a finite number, N, of vector snapshots, each sized (L_{vec} \times 1) (afflicted with random...
  44. matqkks

    MATLAB Matlab or computer algebra systems

    How does Matlab or computer algebra systems find derivatives of functions? Is it correct that they use matrix transformation?
  45. J

    MATLAB Calculating and Plotting the n-Point DFT of a Signal in MATLAB

    Hello I am trying to calculate the n-point DFT of a signal using fft where n=512 and plot it in matlab. The signal is a separate file that I have read into matlab. I am able read and plot the first 512 values of the signal but when I try to get the dft of the signal and plot it the outcome does...
  46. K

    MATLAB Matlab class array / other array

    Okay so what does this line of code mean: snleg = strtrim(cellstr(num2str(alf_deg.'))); I did some research and it is ultimately removing whitespace (comma's, spaces etc) from a file scanned in, but I don't understand the argument of the function. I don't understand what cellstr is or...
  47. E

    Error in defined expression for Fresnel equation in matlab ( please )?

    error in defined expression for Fresnel equation in MATLAB (urgent please )?? hi i have code for plotting Fresnel equation but there's something i didn't understand it and gives error >>((( plotopt - plotting option (type 'R' for plotting reflectivity, % 'A' for absorptivity or 'RA'...
  48. E

    MATLAB Summation x^2 0-3 w/o Built-in Matlab Fns: For Loop

    How can I do the summation of x^2 from 0 to 3 without the use of any built-in functions? I know a for loop is involved, but I can't get it to work.
  49. R

    MATLAB What is the error in running Newton's Method in Matlab for a specific function?

    I've been using this for a Newton Approximation in Matlab function x = Newton(f, fp, x, nmax, e) % f is an inline function which we apply Newton's method on % fp is an inline function that is the derivative of function f % x is the initial guess of the root % nmax is the total number...
  50. R

    MATLAB Implementing Bisection Method in Matlab: Troubleshooting Error Message

    Here is the code I have, but I keep getting the error message: Undefined function 'f' for input arguments of type 'double'. I don't know what I have that is causing this. Does anybody see what's wrong with my code? MaxIt = 1000; epsilon = 10^-5; a=1; b=2; c = (b+a)/2; NumIt = 0...
Back
Top