Read about matlab code | 44 Discussions | Page 1

  1. J

    A 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...
  2. F

    Engineering 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 !
  3. 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...
  4. Leanne

    Finding the diameter of a wire

    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...
  5. 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...
  6. hagopbul

    MATLAB 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 =...
  7. 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...
  8. 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...
  9. 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...
  10. R

    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...
  11. ItsTheSebbe

    Engineering 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}$$...
  12. 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...
  13. T

    MATLAB Convert R code into matlab

    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){...
  14. A

    Transfer function of a curve

    How can i calculate transfer function of curve? for example from time response of a curve. or transfer function of ferquency response .
  15. 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...
  16. 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?
  17. 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...
  18. 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...
  19. 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 =...
  20. A

    Electric field of AC source

    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...
  21. 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...
  22. 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...
  23. 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)...
  24. N

    MATLAB How to plot these figures?

    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 =...
  25. 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...
  26. 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...
  27. 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...
  28. S

    Comp Sci Matlab code to Python

    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...
  29. 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...
  30. 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...
Top