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.
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...
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 =...
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...
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...
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...
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...
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...
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...
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...
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 =...
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...
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...
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...
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...
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...
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}$$...
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...
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){...
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...
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?
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...
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...
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...
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...
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...
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 =...
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...
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...
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...
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...
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...
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)...
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 =...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...