Matlab code — 129 discussions

  1. L

    How do I sample a continuous signal x(t) to create x[n] in MATLAB?

    Homework Statement x(t)=4sin(0.5t).3u(t) x[n]=x(n2Ts) The 1st equation, x(t)=4sin(0.5t).2u(t) Code : >> A=2; >> wo=0.5; >> t=5:0.25:50; >> x=A*sin(wo*t).3*(t>=0); >> plot(t,x), grid on >> xlabel('t (s)'); ylabel('Amplitude(unit)') But the second one,x[n]=x(n2Ts), I don't know...
  2. A

    MATLAB MATLAB code for semiconductor laser rate equation using finite difference

    Can anyone help me by giving MATLAB code to simulate semiconductor laser rate equation by finite difference methord. i wrote a code but that was not working. so i need it badly. please help me.
  3. M

    Is My MATLAB Code for Heat Transfer Correct?

    Hi so i have a heat transfer project to determine the material (aka the thermal conductivity) and length of a 2d wall. It has to have between -1 and 1 net rate of heat loss from the southern side and above 145 rate of heat transfer from the eastern side. The wall is 20 cm high na the boundary...
  4. MathematicalPhysicist

    MATLAB Why Is My MATLAB Code Not Working?

    Hi I tried to run this code, but to aveil (both in MATLAB and in mathematica). In the attachment there's a printscreen of the code and the errors, can someone help me with this? Thanks.
  5. M

    Matlab code but i'm having problems puting in a loop

    Hi. i have seen similar questions on here but can't quite get them to apply to my problem i have wrote some MATLAB code but I'm having problems puting in a loop heres my code ----------------------------------------------------------------------------------------- clear clc for...
  6. J

    MATLAB MATLAB code (calculating displacement)

    Hey guys, I need help. Say i take a picture of a dot in a frame followed by another picture whereby the dot has moved to another spot in the frame. How do I calculate the distance between these 2 dots? At the end, i would have 2 jpeg images of the dot at 2 different locations. What I'm trying...
  7. R

    MATLAB Transforming a matlab code

    Hi fellows! I need a bit of help with transforming a MATLAB code that simulate magnetic field of two concentric solenoid TO a plot that simulate the magnetic fields of high voltage transmission lines (specificly two and four lines), how can it be modified? here is the code: % GKLmagnet2.m...
  8. M

    MATLAB Converting a normalized gradient equation to MATLAB code

    We need a MATLAB code for a normalized gradient eq. help! :) Hello, we need help in converting this normalized gradient equation into a MATLAB code. Please see the image. Thanks! :) http://img706.imageshack.us/img706/7998/thesisformula.jpg
  9. S

    MATLAB Trying to speed up some MATLAB code

    Hi guys, I've got some MATLAB code that calculates the forward kinematics for a robotic arm. This calculation relies on the successive multiplication of a series of 4x4 matrices, and currently I have this coded (more or less) as: ... T(:,:, 1) = T0; for i = 2:njoints T(:,:, i+1) =...
  10. A

    MATLAB MATLAB code for Rutherford scattering trajectory won't run

    What's wrong with this MATLAB code for Rutherford scattering, it won't run for me! :( Hi, I can't do matlab...and have to plot the trajectory of alpha particles in rutherford scattering. I've made an attempt, but i know I've gone wrong somewhere. Could someone tell me how to fix it? I'd be...
  11. C

    MATLAB MATLAB shooting method loop stuck between two angle values

    Hi, I am trying to use the shooting method to determine the angle of a projectile. However for some values of distance and initial velocity my value for angles get stuck between two values. I want to put a piece of code into my shooting method which can either detect that my while loop has...
  12. C

    MATLAB Reading sparse matrices in CSR or CSC format and computing eigenvalues in MATLAB

    Hello. Can anyone help me in producing a Matlab code that will read a sparse matrix and then calculate the eigenvalues of it, show the sparsity pattern of it etc. I have the the sparse matrix data in compressed sparse row (CSR), compressed sparse column (CSC) formats and also in Co-ordinate...
  13. A

    MATLAB Matlab code for extracting random subwindows/subimages

    hi, I am doing project related to object recognition using decision trees and random subwindows.For which i nee d MATLAB code for extracting random subwindows/subimages(size is 16x16) from the image files and after that i need to get the gray values of the subimages.
  14. L

    MATLAB How can I attach MATLAB code in LaTeX without it looking like a report?

    Hello! Im writing a technical report with "article" as documentclass in Latex. I want to attach my MATLAB code in the appendix. If I copy and paste the text it won't look like the MATLAB code but it will look like a report.. What command should I use so the text just looks like it is ...
  15. E

    MATLAB How do I implement a recursive function efficiently in MATLAB?

    Hello, I have the following equation, and I want to program it using MATLAB. But it is a recursive function, and it seems that I can not handle it well. So please if anyone can help, I will be thankful.
  16. P

    MATLAB Solving a 2D heat equation with moving source in Matlab

    Hi i Would like to solve the the following eqn using Matlab Since I am new to Matlab, I would request u to help me in this regard (∂^2 T)/〖∂r〗^2 + 1/r (∂T )/∂r+(∂^2 T)/〖∂z〗^2 = 1/α (∂T )/∂t+τ/α (∂^2 T)/〖∂t〗^2 - { (1+δ(t) )-(1+δ(t-tp) }*IoKa/k 〖exp( - 2r/σ^2 〗_^2)exp(-zka) where δ(t) =76ns...
  17. P

    MATLAB Solving a piecewise thermal equation in Matlab with different materials

    Hi i Would like to solve the the following eqn using Matlab Since I am new to Matlab, I would request u to help me in this regard (∂^2 T)/〖∂r〗^2 + 1/r (∂T )/∂r+(∂^2 T)/〖∂z〗^2 = 1/α (∂T )/∂t+τ/α (∂^2 T)/〖∂t〗^2 - { (1+δ(t) )-(1+δ(t-tp) }*IoKa/k 〖exp( - 2r/σ^2 〗_^2)exp(-zka) where δ(t) =76ns...
  18. P

    MATLAB Solve thermal equation in MATLAB with material properties in two regions

    Hi i Would like to solve the the following eqn using Matlab Since I am new to Matlab, I would request u to help me in this regard (∂^2 T)/〖∂r〗^2 + 1/r (∂T )/∂r+(∂^2 T)/〖∂z〗^2 = 1/α (∂T )/∂t+τ/α (∂^2 T)/〖∂t〗^2 - { (1+δ(t) )-(1+δ(t-tp) }*IoKa/k 〖exp( - 2r/σ^2 〗_^2)exp(-zka) where δ(t) =76ns...
  19. D

    How to Adjust MATLAB Code to Correctly Draw a Diamond with Even Sizes?

    i need to build a code which asks the user for the size of the desired diamond and then draws it, i can get this to workl perfectly by using the fprintf command and building the diamond out of 4 parts,: see code- clc clear h=input('enter height of diamond :'); y=1; while y<=h/2 for...
  20. T

    MATLAB How do I sum over n in a MATLAB biphasic model equation?

    i need to write this into MATLAB http://www.engin.umich.edu/class/bme456/ch10fitbiphasic/biphasfit19.gif which i have done here: uj = (-sig/Ha)*(xj-(((2*h)/(pi^2))*((((-1)^n)/((n+1/2)^(1/2)))*sin((n+1/2)*((pi*xj)/h))*exp(((-Ha*ko)/(h^2))*((n+1/2)^2)*(pi^2)*t)))); how do i vary n...
  21. C

    MATLAB How do I express a system of linear equations as a matrix multiplication in MATLAB?

    Hihi, Let's say I have the linear equations ,A 2x +3y +4z 5x+6y-7z 5x-4y+3z then I can always write as a matrix multiplication A= B*x matrix B = 2 3 4 5 6 -7 5 -4 3 times matrix x x y z Then., how can I tell MATLAB to express in the matrix multiplication form so...
  22. D

    MATLAB Matlab recursion alternating between two values instead of converging

    This is some Matlab code that my group has been working on. None of us really code all that much, and have only had one year of Comp Sci. It doesn't help that this is all our our first times using Matlab, either. :/ The problem is calculating a value for a and aPrime. We're trying to use...
  23. M

    MATLAB Matlab code to calculate minimum distance

    hey guys, i want to wirte a function which takes as its arguments two lists of co-ordinates (the first is a list of customers and the second for possible switch locations), and determines the index of the best switch location to minimise the amount of cable required. I have done the...
  24. U

    MATLAB Matlab code looking good? EE_Signals

    Homework Statement Graph of x(t) = 9e^-2t for t>=0 and y(t) = 4e^(-9*pi*t). Is my MATLAB code correct? I did it by hand and I'm getting a different answer, so I don't know which one is the correct one... if my hand one is correctly done or if the MATLAB one is correct. I'm learning MATLAB on...
  25. U

    MATLAB Convolving 0.2(1.3)^n with sin(n*pi/2) in MATLAB

    Homework Statement A DT system has the unit response h[n] = (0.2(1.3)^n)u[n]. You then input x[n] = sin(n*pi/2)u[n]. Find the convolution. Homework Equations None. The Attempt at a Solution >> n = 0:30; >> h = 0.2*(1.3).^n; >> x = sin(n*pi/2); >> s = conv(h,x); I left out u[n] because we...
  26. S

    MATLAB Matlab code for transient 2 D thermal problem

    hi i want MATLAB coding for transient 2D Thermal problem pls help
  27. ranger

    MATLAB Whats wrong with this matlab code?

    I have a very simply MATLAB code. When I try go run it, I get no graph and switching over to the MATLAB command line, I see: ans = char Here is the code: t = linspace(0,60); v = 3.22; for q_0 = [0:1:2007]; q = q_0*exp(v*t); plot(t,q) hold on end It looks just...
  28. J

    MATLAB Get MATLAB Help - Free Assistance from Experts

    MATLAB code help please... Hi, My name is Jennifer.Iam new to Matlab programming.Iam working on reducing the noise content in audio communication.Iam using Hamning codes for the same.I have a sample code with me,which iam uploading in a zip file.Iam unable to understand how it works.Can...
  29. M

    MATLAB Debugging golden section search algorithm in MATLAB

    Optimization: I am going insane here :cry: :cry: I've really run out of ideas... please help me.! %golden.m function [f,a]=golden(func,p,tol) func='dfunc'; p=[0 1] g=0.38; a=p(1); b=p(2); r=b-a tol=0.01; iter=0 while r>tol x=[a+g*r b-g*r] y=feval(func,x) if...