What is Matlab code: Definition and 142 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. D

    How can MCNP code be used to calculate photoneutron doses in radiotherapy?

    I worked monte carlo simulation for dose calculations in field radiotherapy (external and brachytherapy) using EGSnrc and MCNP codes.
  2. D

    Resultant pedal force (FRESULTANT) Force tangential to the crank arm

    %% part 1 clear all; close all; clc; torq_crPK = zeros(10,1); ang_tqPK = zeros(10,1); ang_powPK = zeros(10,1); torq_crDS = zeros(10,1); torq_crUS = zeros(10,1); WD = zeros(10,1); WDpos = zeros(10,1); WDneg = zeros(10,1);%% INPUT VARIABLES for i=1:10 % cyclist number % read in the...
  3. 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...
  4. 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 =...
  5. F

    Find Z-bus using Z building algorithm using MATLAB code

    I tried to write to the code, but I got confused in line 46 & 59.Every new added bus increases the dimension of the Z matrix, and since we have 3 busses, the dimension of Z should be [3x3]. I formed a for loop in case of adding a new bus to add a new row and new column (increases the...
  6. F

    Write MATLAB code to find Y bus for any bus system

    Here's my work: clc; clear all; % Ybus by step by step method for an any bus system % | From | To | R | X | gsh | B | T|ysh % | Bus | Bus | pu | pu | pu | pu | ph-sh linedata = [1 2 0 -5 0...
  7. J

    MATLAB Writing a matlab program to solve the Kepler Problem (Universal Vars)

    Introduction: I am writing a Matlab program that solves the Kepler problem for any Elliptical, Hyperbolic, or Circular orbit. Given an initial position vector, velocity vector, find the position vector and velocity vector after some given time. I am not doing this for any class, I have been...
  8. F

    Solve a nonlinear equation using fixed-point iteration in MATLAB

    My attempt is attached below. When I tried to solve it , nothing comes up. However, there are no errors !
  9. N

    How to judge the singularity of a matrix in numerical method?

    Summary: different methods give different results. They are not consistent. Summary: different methods give different results. They are not consistent. I use two different methods to detect whether a matrix is singular. The result of calculating the determinant of a 9-order square matrix is...
  10. Leanne

    How Do You Find the Diameter of a Wire Using Voltage and Length?

    Mentor node: Added code tags From=menu('select:','c', 'g', 'a', 's:'); This is part of my code and I'm not coming up with anything close l=input('input wire length') %current copper=12.5572...
  11. H

    MATLAB My Crank-Nicolson code for my diffusion equation isn't working

    I'm trying to solve the diffusion equation in spherical co-ordinates with spherical symmetry. I have included the PDE in question and the scheme I'm using and although it works, it diverges which I don't understand as Crank-Nicholson should be unconditionally stable for the diffusion. The code...
  12. person123

    MATLAB MATLAB Code For Analyzing Experimental Data

    Hi! I'm working on MATLAB code to analyze dat for a specific project, but I'm curious if it could made useful for more general purposes. Here's a bit of background on the project: I'm an REU student and I was assigned to analyze data for a recently conducted experiment. The experiment took...
  13. hagopbul

    Java Why is this Java code not working?

    Hello all: I am reading a comutacomputa physics book and trying a code from it in MATLAB it is not working and due to my lack of knowledge in this field I can't see where is the mistake hope you can take a look import java.lang .*; public class Motion { static final int n = 100000, j =...
  14. D

    1D Angular Motion with different velocity stages

    Homework Statement I am solving a kinematic problem, where I have a link that is attached to a rotational joint. I need to find the position of the joint for t=0..8, and I need to do it for every 0.01s. The problem comes from the fact that I have three stages for the velocity, during t = 0..0.1...
  15. Baynie

    MATLAB Code: Stationary Schrodinger EQ, E Spec, Eigenvalues

    Hello everyone, For weeks I have been struggling with this quantum mechanics homework involving writing a code to determine the energy spectrum and eigenvalues for the stationary Schrodinger equation for the harmonic oscillator. I can't find any resources anywhere. If anyone could help me get...
  16. T

    NSGA II and objective function in matlab

    Homework Statement I would like to solve a multiobjective optimization problem with NSGA II using matlab. The code can be found here https://www.mathworks.com/matlabcentral/fileexchange/10429-nsga-ii-a-multi-objective-optimization-algorithm I'm looking for a help to implement my objective...
  17. D

    How to use the window functions on a signal in MATLAB?

    Homework Statement I am suppose to write a program that compares the FFT (Fast Fourier Transform Diagrams) of a sampled signal without the use of a window function and with it. The window function should be as long as the signal and the signal should have N points, N chosen as to not cause...
  18. R

    Plotting Free Body Diagram for Scalar Triple Product in MATLAB

    Homework Statement [/B] The scalar triple product computes the magnitude of the moment of a force vector about a specified line. It is M = ( r×F ) ⋅n , where is the position vector from the line to the point of application of the force and is a unit vector in the direction of the line. Prompt...
  19. ItsTheSebbe

    Finding the bandwidth of a parallel RLC circuit (+MATLAB)

    Homework Statement The attempt at a solution Constructing the total impedance of the circuit as follows, $$\frac{1}{Z_T}=\frac{1}{Z_R}+\frac{1}{Z_C}+\frac{1}{Z_L}$$ where $Z_R=R$, $Z_C=-j\frac{1}{\omega C}$ and $Z_L=j\omega L$. $$\frac{1}{Z_T}=\frac{1}{R}+j\omega C+\frac{1}{j\omega L}$$...
  20. R

    MATLAB Finite element skeleton code for matlab

    Hello, Does anyone know if a finite element skeleton source code exists. Finite element can be used for structural memebers, gas dynamics, etc. But the over all stepping software is the same and then just input the core equations. My application is for pseudo one dimensional compressible...
  21. T

    MATLAB Convert R Code to MATLAB for Detrended Cross Correlation Analysis

    Homework Statement I would like to convert this R code into matlab. This code perform a calculation of beta coefficient based on Detrended cross correlation analysis. Homework Equations require(tseries) require(fracdiff) require(matrixStats)DCCA_beta_avg<-function(y,x,smin,smax,step){...
  22. A

    Calculating Transfer Function of a Curve: A Beginner's Guide

    How can i calculate transfer function of curve? for example from time response of a curve. or transfer function of ferquency response .
  23. D

    Problem with plotting a function in MATLAB

    Homework Statement Write code for solving the integral ##\int_{0}^{x}e^{-t^2}dx## using simpsons method and then plot the function from ##x = 0## to ##x = 5## with ##0.1## increment. Homework Equations 3. The Attempt at a Solution [/B] I was told that the best way to plot the function is to...
  24. Nikhil N

    MATLAB How can I run Python by getting values from Matlab

    I have a python script for which the input data are coming from Matlab. I have tried to use pymatlab, but it is failing. Can anyone suggest any other method?
  25. grandpa2390

    MatLab Code for Baseball Not Working

    Homework Statement I am trying to create this plot in MatLab I'm starting out doing the simplest one, no drag, no wind. simple kinematics, right? but I can not get my code to run. Homework Equations Kinematic Equations The Attempt at a Solution close all clear all clc %%defining variables...
  26. grandpa2390

    Why Won't My Matlab Code Work?

    Homework Statement I need to write a program in Matlab that accomplishes this graph: I keep getting an error on Line31 Column 161 about unexpected parenthesis. They look balanced to me. If I take one away from either side, I get an error that I am short a parenthesis. I also need to change...
  27. M

    MATLAB Suggestions for a non-linear fit model in Matlab

    Good afternoon, I have a problem which I haven't solved yet, regarding a non-linear fit to a set of experimental data. I tried to solve it in Matlab, which I handle a little bit. I have a sensor, which has been designed to have 4 different filters in front of it. By making a sweep with the...
  28. P

    MATLAB Help with MATLAB music code | Signals & Systems

    For my signals and system class were creating music. I am given a structure with three variables, frequency/notes, duration, and pulse. ex: frequency(in note numbers which i then convert to frequencies)[44 45 47 50...]. duration[2 1 1 3 4...] with pulse duration being .25s and pulse[1 3 4 5 8...
  29. C

    MATLAB function within function handle output

    Homework Statement MATLAB The funciton "rockdynamicstage" outputs a matrix 4 by x, where x is somthing around 300( varies). The funciton "rockdynamicstage" is within the funciton handle "sim" with an input of gama0. (PayMass,Masstages,Massfrac,Thstage,IspStage,ChangeTstage) ar parameters that...
  30. TaylorLL

    MATLAB MATLab: Not enough inputs for nlinfit

    Hello! I'm trying to plot a best fit for some generated EQ data and I'm having issues with nlinfit. My code is as follows and when I try to run it, I get an error referring to the anonymous function ("test"), nlinfit (from Matlab), and not having enough input arguments. %Test function t =...
  31. D

    MATLAB Matlab code for a Gillespie type reaction (model) with wolves and elk.

    Copy and paste if you want to use any of this code. Its a simple iteration of converting biomass of elk into new wolves. % example for ODE and Gillespie % one reversible reaction b1 = .033; bo = .00047; a1 = .0022; ao = .00055; Aini = 5168; Bini = 34; %% Basic ODE simulation dt = 0.01...
  32. PainterGuy

    MATLAB Fixing a Matlab Code: Help Needed for Fourier Transform Calculation"

    Hi Could you please help me to fix the code below? I know that the code is completely wrong but I have tried to write it down so that you can get an idea what I'm trying to do. Thank you. %%file name fourier.m clear all; close all; clc; f = 0; %% 0 Hz to 100 Hz, with 0.1 step...
  33. I

    MATLAB Small matlab code not working. Why ?

    Code is the following : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% xiter=[0.7 20 10]; mubeton=[0.100 0.80 0.70 0.60 0.50 0.25]; muair=[0.05 0.042 0.04 0.032 0.021 0.011]; zl=[5 30 70 100]; fnorm1 = @(d,a0,dmax) (a0*(1-exp(-(0.5*log(d./dmax)).^2))+exp(-(0.5*log(d./dmax)).^2)); fnorm2 = @(d,dmax,DRL)...
  34. A

    How Do You Calculate the Electric Field of an AC Source in MATLAB?

    Hello everybody I got really confused. I want to calculate the Electric-Field of an alternating current source( Sine(wt)). I do not know what is its equation. I need to run it in Matlab to get a result. Can you please give me some hints? I need to write the equation to calculate the E-field in...
  35. N

    MATLAB Why 2 vectors are not the same in matlab?

    I have 2 vectors: a = 1.0e-04*[0.110000000000000 0.140000000000000 0.140000000000000 0.140000000000000]; b = [0.000011000000000 0.000014000000000 0.000014000000000 0.000014000000000]; by look at by eyes, it seems similar; but when I use this command: a == b then I got...
  36. D

    I don't get a reasonable output for my code?

    I'm trying to plot the probability of error for the following equation using Matlab software, i want to use the command "trapz" for the numerical integration, the problem is that i get a fine shape for the plot, but the values in the y-axis are wrong, the whole curve should be between 0 and 1.2...
  37. S

    I Working out the equation for coordinates on a graph

    I have a series of data points for X and Y points on a graph. The data is quite random and I am trying to work out a trend line so I can then form an equation for the line. How would I go about working out the equation for the data below. (0, 580) (6.7, 495) (13.4, 445) (18.7, 365) (22.8, 350)...
  38. N

    MATLAB Learn How to Plot Figures in MATLAB: Step-by-Step Guide and Helpful Tips

    Dear group, I am new with MATLAB and trying to plot these figure out as the file request. I tried but could not get the same plot as the file has. I hope anyone can help. Here is the code which i am working on. Thank you. fc = 553e6; w = 0:2*pi*fc*1e-2:100*2*pi*fc; pau = 0.33; tau =...
  39. P

    Matlab code problem with differential equations

    Homework Statement For a following differential equation d^2y/dx^2-4y=(e^x)/x  Find the solution using numerical methods Homework Equations d^2y/dx^2-4y=(e^x)/x The Attempt at a Solution %num dx=0.01; x=1:dx:3; l=zeros(1,length(x)); m=zeros(1,length(x)); l(1)=1; m(1)=0.25; for...
  40. kelvin490

    MATLAB How to make 2D plot of points with different colors?

    I want to make a 2D plot of points with different x, y coordinates and have colors depending on a separate variable. I have make column vectors for x and y coordinates and another column containing 1 or -1. I would like to represent the points with 1 as red and -1 as blue points. I have codes as...
  41. Ketav

    Solving a System of 2 ODES with Interval conditions

    Homework Statement I am trying to solve a system of 2 ordinary differential equations using matlab. However, I am not able to get numerical solutions from the code despite having keyed in all possible solutions. Homework Equations The equations I am given are: dx/dt=A(x/t)+By...
  42. S

    MATLAB Python to Matlab Conversion for fscanf & DWT

    Hello, 1. Homework Statement I find diffuculties to transform fscanf and to apply the discrete wavelet transform order 2 from matla to python. Homework Equations This is the MATLAB code: D_P=fopen('distance_profil.txt','r'); i=0; while(feof(D_P)==0)% test for end of file i=i+1...
  43. jiaying

    MATLAB Matlab -- how can i use a FOR loop if I have 2 variables changing

    Hey,for following code the 3rd loops i need to have 2 variables m and q .Could anyone help? for t=1:maxiterations toterror=0; for j=1:numfeature totslope=0; for i=1:m&&q=1:numfeature z=0; for jj=1:numfeature...
  44. A

    I Plotting the orbits of the planets

    Hello everybody! Long-time lurker and second-time posting. I'm working on a project for my math class, and I'm trying to plot the orbits of the planets using vectors. I've chosen to use MATLAB because I am decently familiar with it. I've used the formulas described in this post here to get my...
  45. B

    Disappearing energy from a series connection of coupled oscillators

    I have been having trouble getting the calculation of energy for a chain of coupled oscillators to come out correctly. The program was run in Matlab and is intended to calculate the energy of a system of connected Hooke's law oscillators. Right now there is only stiffness and no dampening...
  46. KonaGorrila

    MATLAB How to get the last variable of a for loop in MATLAB

    Aloha guys, I am just having trouble getting MatLab to output only the last variable of my "for loop." If anyone can help all I am looking for is an example of notation. p.s. I have done this before just not in a while and will continue to look through my old scripts and functions. just not in...
  47. I

    I How to turn model of Schrödinger's Equation 2D?

    Hi, I am a student in the Netherlands, currently 17 years old and at the end of my 'middelbare school', meaning that next year I'll be a bachelor student at a university. I am doing an extended essay/research thing that is custom you do in your last year, with a friend of mine. We picked the...
  48. B

    Problems with Matlab code for simulating spring motion

    The issue I am having is setting up the actual program for the problem. I am having trouble interpreting the code and, because of that, having issues getting it to work properly. The whole thing was written with Matlab and the goal was to write a function that could simulate the motion of a...
  49. J

    MATLAB Solving Orbital Motion Equations with RK4 Using MATLAB

    I'm trying to plot the solutions of the second order differential equation d^2R/dt^2 = GM/R^2 + Lz^2/R^3. I'm reducing this to a system of first order ODEs and then using RK4 to solve this system. My code is given by function RK4system() Tsim = 10...
  50. I

    MATLAB Transforming part of matlab code to Fortran90

    Here are my Fortran codes: program test implicitnone integer*4 nxProjPad, cf, numViews, cc, index, indRad, iv, i, INDEX1, d, n real*4 v4, v5, RSS, S1, F1, gMDL real*4, dimension(:), allocatable :: array, sum, cumsum, transpose, log, SS1, SSs nxProjPad=185 numViews=180...
Back
Top