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

    MATLAB Animating Vector Addition in Matlab (Looking for improvements)

    Here is my code thus far and it seems to work (I've attached a gif as well so hopefully that works) va1 = [50*cos(pi/3), 50*sin(pi/3)]; %Two different vectors both starting from the origin vb1 = [20*cos(pi/6), 20*sin(pi/6)]; iterator = linspace(1,100,100); %100 iterations for the animation...
  2. M

    MATLAB How do I write this chua oscillator to an audio file in matlab?

    hello i would like to ask how to write the solution of this matlab program to an audio file using the audio tool box or any other technique. thanks very much. function chua_oscillator %This program is computed by S.Sabarathinam %Based on: Nonlinear Dynamics: Integrability, Chaos and Patterns,by...
  3. T

    MATLAB Matlab's numeric solution to det of Matrix is incorrect

    Hello everyone, I have an equation derived as the det of a matrix, which I have solved in Mathematica 11 with Findroot and verified with the respective PhD Thesis' data. However, I now try to get more accustomed to Matlab (R2017b) and hence I tried to reproduce the problem and find its solution...
  4. Ugnius

    I need sources to learn about dynamic systems

    Hi! I have exam in couple of weeks , and now am looking for sources to learn about dynamic systems , chaotic systems and etc. My main goal is to learn characteristics of such systems , learn about special points in dynamic plane. For the most part we used to create dynamic system simulations...
  5. ergospherical

    MATLAB Streamline Symbolic Derivatives with MATLAB's Simplify Operation

    I am using MATLAB to compute a few symbolic derivatives. The outputs are correct (I've checked a few of them) but usually long and never simplified (even when "obvious" simplifications are possible, i.e. combining terms, cancelling things). Is there a way to get MATLAB to simplify symbolic...
  6. M

    Engineering How to implement a transfer function in Simulink with variable coefficients?

    The implementations for the two filters in simulink are as follow: For the first filter: For the second one: The obtained results have values of 10^-12, while the expected results should be between 10^-3 - 10. Since it's the first time when I try t implement a tf with variable coefficients I...
  7. DiracPool

    MATLAB Help converting MATLAB to Scilab code

    Hello, I am having difficulty converting some MATLAB code to Scilab code. Specifically, the problem is with graphing the results of a spiking neuron program. Herer is the program and the article that explains it: https://www.izhikevich.org/publications/spikes.pdf The problem I am having is...
  8. V

    Using Newton's Method to Solve and Using Fsolve in Matlab

    Here is my code so far and solution. When using fsolve, we obtain the result that the equation does get solved. We find the values to be 1.0000, 0.0000, and 2.0000. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the...
  9. V

    Solving An IVP on Matlab with ODE 45 with different tolerances

    My code is as follows: but when I use the function in my command window exactsol(t) and input a tolerance but there is an error in LINE 19 saying unrecognized ivpfun, could someone help me fix it as I am unsure of how to proceed from here. function y = exactsol(t) y = zeros (2,1); y(1) =...
  10. V

    Using ODE45 on Matlab to Integrate A Problem

    I got the answer for this question but I was wondering about stepsize when it comes to a problem like this? Is there a way to change the step size? Would my step size change in line 20, or would it change in line 3? I tried changing line 3 to be t=0:100:17.1 but then I get a error message, so...
  11. S

    Pendulum Question (Matlab Coursework)

    Apologies for my lack of knowledge on the equations front, I have burnt by brain out on this and haven't the capacity to learn LaTex right now! So here's a screengrab of it: So, This is a Matlab coursework and I am struggling to work out how best to approach solving it. What I have so far is...
  12. V

    Matlab Function for Composite Simpson

    function I=main_simpson(a,b,tol) f = @(x) sin(1./x); SO = 0; N = 10; S = 1; while (abs(S-SO)>tol) SO = S; h = (b-a)/(2*N); i = 0:N-1; xi = a+2*i*h; xi1 = a+2*(i+0.5)*h; xi2 = a+2*(i+1)*h; S = (h/3)*sum(f(xi)+4*f(xi1)+f(xi2)); N = 2*N; end end <Moderator's note...
  13. V

    Analyzing while loop in matlab

    I am confused why this is the case, why would it output that number? When I go through the code, there is (x+1)-1 which does equal 1, then x = 2*x is 2? So why is the output not 2? How should I proceed in coming up with a solution? Does this have something to do with cancellation errors somewhere?
  14. V

    Creating Plots using Matlab For Interpolation

    My code in Matlab for this practice question is: ( x = linspace(0,4,10); y = sqrt(x); plot(x,y,'-o'); hold on y2=polyfit(x,y,2); plot(x,y2,'--or') ) Is this the best way to do? My plots look nearly identical and are on top of one another but a later question asks to graph the error, so I am...
  15. T

    MATLAB FEM, Matlab and the modes of an element

    Hello I wrote a Matlab code to form the 8 by 8 stiffness matrix of a single, 4-noded element, for a plane strain problem for an isotropic element. I conduct an eigenvalue analysis on this matrix Matlabe reports 5 non-zero eigenvalue modes, and 3 zero-eigenvalue modes (as expected) Of the 3...
  16. V

    Determining The Matlab Output

    I am having a bit of trouble understanding what the values of g(x) and h(x) mean. I went through it by hand and here is information that I gathered about the values and questions I am trying to answer to gain a better understanding. Firstly, for the value of x=1e-10 both the numerator of g(x)...
  17. V

    Creating a Double Precision Matlab Function from Scratch

    I am confused at how to code this without using any of matlab's already built in functions except for using double. Is this question just asking me to write out the function and then make sure it's double precision?
  18. ergospherical

    MATLAB Curve Fitting in MATLAB: Error Diagnosis

    I have two 1D matrices X(1,j) and Y(1,j) of equal length. To fit Y to a model asin(bx) I tried: fit = fittype(@(a,b,X), a*sin(b*X)); [fitted, gof] = fit(X, Y, fit) coefficients = coeffvalues(fitted) this gives the message: Error using fittype>iDeduceCoefficients The independent variable x does...
  19. M

    MATLAB Can I run sections of code independently in Python and C++ like in MATLAB?

    Hi PF! I typically code in MATLAB. Here, if I run the following program %% Section 1 x = 5; y = 2; %% Section 2 z = x + y; everything works. But now let's say I wanted to change line 5 to z = x - y. In MATLAB this is simple: I can simply change line 5 and rerun section 2. Is there a way to...
  20. tworitdash

    MATLAB Closed form not the same as the discrete form

    clear; lambda = 3e-2; x = 4 * pi/lambda * linspace(eps, 15, 100000); T = 5e-3; t = [0:0.001e-3:T] ; % 0.1:1e-3:0.1+T]; u = 3; a = 4*pi/lambda * u; for i = 1:length(x) Z(i) = sum(-((cos(a.*t) - cos(x(i).*t)).^2 + (sin(a.*t) - sin(x(i).*t)).^2)); end % Z1 = csc((a+x)/2) .*...
  21. P

    MATLAB Phasor diagram - how to check angle in matlab?

    I have a problem with checking angle in phasor diagram. I print my phasor diagram and I don't know how to check angle in window. Have somebody any idea how to search that? Maybe it is not possible and I need to add function in my MATLAB code to get result.
  22. M

    MATLAB How to load data from the example supplied on MATLAB website?

    The demo here doesn't specify how to download the file dowPortfolio.xlsx from the first line in the tutorial: T = readtable('dowPortfolio.xlsx'); Any help here (please tell me it's not just me)? Nevermind, evidently you literally can just copy that line into the command window and MATLAB...
  23. JD_PM

    MATLAB How to plot flow data from an orifice in MATLAB without overlapping the plots?

    I am studying a flow going through an orifice. I am aimed at overlapping the plots for the speed distribution over the vertical width profile (which is 0.015 m long; highlighted in red) for two downstream, horizontal distances [w.r.t. the orifice]: 0.01 m and 0.03 m. The result should look...
  24. W

    Solving Freidman Equation on MATLAB

    I have to use MATLAB to solve the Freidman Equation and I have barely any computer programming language skills whatsoever. Is there anyone that can please help me solve the equation using MATLAB. I desperately need help in this area because my Professor won't show me how like he expects me to...
  25. mcas

    Calculate Conductivity Temperature Dependence in Semiconductors

    I have to plot the conductivity dependence of temperature and I have problems with obtaining the right dependency of \mu and n. But let's focus only on carrier concentration first. For n I used the third equation. From what I understand N_D is a constant. I want my plot to look like this: But...
  26. S

    Hello new here

    Hello ! My name is Amine, Renewable Energies Student (Thermal Conversion Masters degree) . interested in numerical analysis and applied mathematics . Currently focusing on Heat and Mass Transfer , Fluid Mechanics and Matlab programming. ready to efficiently help on those subjects please...
  27. Dario56

    Extraction Flash Calculation - 4 Component and 2 Phase System

    I am performing extraction flash calculations for 4 component and 2 phase system. For anyone somewhat shaky with what extraction flash calculation is; extraction is performed, feed composition is known and we are calculating compositions of both phases at equilibrium, mole fraction of every...
  28. H

    MATLAB Modelling a Heat Pump with Linear Compressor using MATLAB Simulink

    Hello, I am a final year mechanical engineering student designing a heat pump with a linear compressor for an electric vehicle and have decided to model this using Simulink, I would love some help on the governing equations/formulas needed for each component of the heat pump as well as guidance...
  29. P

    Engineering How do I use Simulink to create a control system with a 2nd order ODE?

    Equation: , where matrix D, C, G and F can be represented by I'm supposed to design a control system that looks like this: I am given that the dynamic model = fcn(D,C,G,dq) where the dq is the same as 𝑞̇ and d2q in the diagram is the same 𝑞̈. The default initial value of [𝑞(0), 𝑞̇(0)] is...
  30. DaveC426913

    MATLAB Learning Curve of Wolfram Alpha or Matlab

    I should probably get one or two of these under my belt. My current need is to plot a ... I guess it's a heat map. I've got a map of my local area and I want to determine the geographical centre of a number of points (say, seven). So, for every xy "cell" on the map, I'll use pythagoras to...
  31. Sai Maurice

    Populating a 1001x101 2D array in MATLAB

    The method I employed was based on a nested loop. I ran into two issues with this approach 1. The code took way too long to run, easily going for over 7 minutes. 2. In the end, it didn't even completely work, due to the "index exceeding the array length". This confuses me For the relevant...
  32. P

    MATLAB Using 2 MATLAB files to simulate 3 plots

    First of all, I'm an absolute beginner in MATLAB. Secondly, I have 2 MATLAB files, one entitled as a "main file" and the other one as a helping .m file, which is called by the main file. I need to run the main file in order to obtain 3 plots. What is the exact procedure that I should follow in...
  33. A

    MATLAB Help with Math: Calculate Manually, No MATLAB Needed

    Can someone help me with this? You don't need to do MATLAB, just compute manually.
  34. R

    MATLAB Learn MATLAB Commands: Website for Variable and Function Explanation

    when I had learned matlab, my professor told me a website where everything is explained about MATLAB variable and MATLAB function. After a long time later, I like to use MATLAB for my work. However, I forget the name of the website. Does anybody tell me the helpful website?
  35. J

    MATLAB Conversion from Mathematica to Matlab

    Hello!. I am new to the forum and I am also a newbie to programming. I want to convert a Mathematica code to Matlab, but I don't understand how to translate these lines. This code is Mathematica 5.0. defvar := Module[{a}, Clear[ cN, cNf, ginix ]; Clear[ Nh, Nhf, gini ]; cN =...
  36. C

    MATLAB Generation of a Gaussian a random process with Matlab

    Hello everyone. I am currently working with Matlab. I have a 2D gaussian kernel constructed using the muKL technique (first attached figure). I want to use it to generate realizations of a gaussian random process using the KL theorem. For that, I obtain then all eigenvectors and eigenvalues of...
  37. Haorong Wu

    MATLAB Optimizing Memory Usage in Matlab: Tips and Techniques

    Hi. I am using Matlab to solve ODEs. I use ode45 in a for loop since solving the ODEs in a single ode45 function yielding an error of "out of memory". However, after the loop has run many times for several hours, the memory will still be full and the program will become slower and slower. If I...
  38. F

    Problem calculating eigenvalues and eigenvectors

    Hello everyone. I am trying to construct a functioning version of randomfields (specifically 2D_karhunen_loeve_identification_example.py) in Matlab. For that, I have to calculate the Karhunen-Loève expansion of 2D data, since this is what it says in the documentation. I also have some sample...
  39. patric44

    MATLAB Change the value of a variable at each time step in matlab?

    hi guys I am trying to implement the a second order differential equation tat contains a time dependent term, the equation looks something like r'' = -\mu/r^3+(g/g^3-m/m^3) the idea is that i want to calculate 'r' the position vector of a point, that is dependent on vectors g and m, I tired to...
  40. patric44

    MATLAB Transforming long symbolic expressions to use in matlab ode45?

    hi guys i build a little function that outputs a symbolic expression like that below, this is only a part of it: (105*(x(5)^2/r^2 - 1)^2)/8 + (210*x(5)^2*(x(5)^2/r^2 - 1))/r^2))/(r^2)^(9/2) + (8*R^7*u*x(5) the problem is the only way to integrate this output is to expand the function externally...
  41. Mohammad-gl

    MATLAB Graphene band structure Matlab code

    I have this code for 3D band structure of graphene but i can't understand why while graphene first brillouin zone is hexagonal but here a rectangle form of first brillouin zone is used?E0 = 0; % coloumb integral V = -2.7; % hopping integral [eV] acc = 1.41; % c-c bond length [Angstrom] lattice =...
  42. tworitdash

    MATLAB MATLAB IFFT doesn't match the analytical one

    I have a Gaussian shape frequency domain spectrum of which I am calculating the Inverse Fourier transform. I use both IFFT of MATLAB and also an analytical expression of Mathematica. They are not the same. I don't know where it is wrong. I have pasted both the figures. The numerical one has...
  43. I

    ODE solver for second Order ODE with Stiffness and Mass Matrices

    i am new to MATLAB and and as shown below I have a second order differential equation M*u''+K*u=F(t) where M is the mass matrix and K is the stifness matrix and u is the displacement. and i have to write a code for MATLAB using ODE45 to get a solution for u. there was not so much information on...
  44. F

    MATLAB Can I calculate the covariance matrix of a large set of data?

    Hello everyone. I want to calculate the covariance matrix of a stochastic process using Matlab as cov(listOfUVValues) being the dimensions of listOfUVValues 211302*50. I get the following error: Requested 211302x211302 (332.7GB) array exceeds maximum array size preference. Creation of...
  45. T

    MATLAB Matlab help — How to replace a word using findstr?

    Matlab help! Hello I want to create a sentence 2 sen1: I love flower str1: love str2: hate How can I create sen2= "I hate flower" using findstr and array concatenation?
  46. tworitdash

    MATLAB Creating and recovering a frequency shift in time domain in MATLAB

    I am trying to simulate and process the Doppler signals. My main problem is a little more complex so I am only posting a simple version of it. Task1: I have a time-domain signal with the velocity of the target as mu. I need to change the velocity to mu cos(theta) where theta is a vector from 0...
  47. C

    A Has anybody programmed the mcKL expansion?

    Hello everyone. I am trying to implement the mcKL expansion proposed in this article using Matlab and two vectors of correlated data of size 1000*50, meaning 50 realizations of two random processes measured 1000 times. As the article says, if two stochastic processes are correlated, one cannot...
  48. C

    MATLAB Problem with Karhunen-Loève expansion in matlab

    I have copied the code of the accepted answer to this post in the official Matlab forums, since I am interested in performing the KL expansion myself. clc clear all y=[1,2,4;2,3,10]; y=y' %Reasons for transposing will become clear when you will read the second point given below...
  49. S

    MATLAB How can I plot a Hohmann Transfer Orbit in MATLAB using ode45?

    function Asteroid_Mining clc %Initial conditions g0 = 9.81; %gravity (m/s^2) p = 1.225; %atmospheric density at sea level (kg/m3) Re = 6378; %radius of Earth (km) Ra = 7.431e7; %distance of Bennu from Earth in (km) [August 2023] G = 6.674e-11/1e9; % Gravitational constant (km3/kg.s2) mu =...
Back
Top