Matlab code Definition and 142 Threads

  1. MAKK

    MATLAB How to Convert Matlab Gaussian Cone Code to C++?

    anyone help me to convert this sample code of Gaussian Cone shape of random number code in Matlab into C++ function GaussianCone clear all; clc; mx=10000; my=mx; mz=mx; z=[1:1:mz]'; sigma=0.01; R=0.5; mu=0; sigmax=sigma+R*z; sigmay=sigma+R*z; x=zeros(mx,1)...
  2. A

    MATLAB Crank-Nicholson in 2D with MATLAB

    I have the code which solves the Sel'kov reaction-diffusion in MATLAB with a Crank-Nicholson scheme. I would love to modify or write a 2D Crank-Nicolson scheme which solves the equations: ##u_t = D_u(u_{xx}+u_{yy})-u+a*v+u^2*v## ##v_y = D_v(v_{xx}+v_{yy}) +b-av-u^2v## Where ##D_u, D_v## are...
  3. N

    4th order Runge Kutta Matlab with 2 2nd order ode

    Homework Statement Hi There! MX''=Fn(sin θ - uCos θ ) MZ''=Fn(cos θ + uSin θ ) - Mg Fn,M,θ,u is constant fn/M = 0.866 M = 6000 θ = 30 u = 0.5774 i split my motion equation into 2 individual 1st ode, X' = Vx Z' = Vz Vx'=[fn*(sin θ - uCos θ )]/M Vz'={[fn(cos θ + uSin θ )]/M} - g...
  4. Lucas94

    MATLAB How to do a double integral on matlab?

    Hey! I want to do a double integral calculation of this problem##∫∫ xy/(xy^2 +1)^2## over the region bounded by 2 ≤ x ≤ 3 and 2*sqrt(1+x) ≤ y ≤ 2*sqrt(2+4x) on MATLAB and i have tried the following syntax: clc clear all fun=@(x,y) x*y./((x*y.^2+1).^2); ymax=@(x) 2*sqrt(2+4*x)...
  5. Tone L

    Storing calculations into a list

    I have a code that loops through and does some computation on 5 random values from my lists of data (2187 rows long). for i = 1:3 randomdata = round(rand(5,1).*2187); xval = x(randomdata) yval = y(randomdata) numerator = length(xval).*nansum(xval.*yval) -...
  6. Tone L

    MATLAB Solving MATLAB Sum Loop Issue with 2,187 Data Points

    So i want to calculate an r value 5 different times then find the mean of the 5 calculated values. I have 2,187 data points. the first line of code generates 100 random points 1-2187. The code has a bug but my major issue is it calculates r then loops again calculates r, loops again calculates...
  7. seyfi

    4th ODE runge kutta (hiemenz equation)

    Hi all i want to write a MATLAB code by runge kutta solution for hiemenz equation. F''' + FF'' + 1 - F'^2 = 0 BCs F(0)=F'(0)=0 and F'(inf)=1 I have programmed for RK Fehlberg, RK4 and RK5 method but the results of these three methods are not matching with actual values. In the cod I defined...
  8. E

    MATLAB 2D diffusion equation, for matlab code.

    https://scontent.xx.fbcdn.net/hphotos-xtf1/v/t34.0-12/12204847_801668796608594_2127169351_n.jpg?oh=f6ea92a40c93e4d843a4bf26a358677d&oe=56404FC5
  9. Tone L

    MATLAB Solving MATLAB Loop with X & Latitudes

    I have a list of latitudes: lats = 41.0100000000000 43.7800000000000 44.4200000000000 41.2500000000000 42.8000000000000 42.7500000000000 42.4900000000000 42.4900000000000 42.7800000000000...
  10. E

    Code of the Angular Spectrum Method

    I constructed my code of the Angular Spectrum Method. However, as the distance between the object and the plane of interest increases, the diffraction pattern never disappears; there is still some sort of a diffraction pattern, and I am expecting that it disappears as distance increases. Here...
  11. F

    Matlab: what is the distribution equal to in Matlab code

    Homework Statement A common way of displaying the distribution of a random variable is by a histogram. Consider the interval [a,b) divided into M sub-intervals (bins) of length ΔX. Given a set of N random values of x, call Nj the number of values that fall within the jth interval. Homework...
  12. T

    Matlab code running loops to meet conditions

    Homework Statement This is not homework but I am trying to solve a problem to see to general a set of numbers for the grassmanian equations to use in something else.[/B] I have five variables a,b,c,d,e. a-b,a-c,a-d,a-e,b-a,b-c,...etc so that none of them are the same so it generates all...
  13. W

    MATLAB Converting Excel formulae into Matlab code

    Hi everyone, I will start off by saying that I am a complete novice in Matlab and prefer to use Excel however the data that I have requires more computing power than Excel can provide. I have 16 sets of data with over 70,000 rows and 9 columns. The first column is a time series separated into...
  14. I

    MATLAB Line following Matlab Code. How to Start?

    So we're using NXT 2.0 and MATLAB to program a robot to follow a white line through a maze. I'm using a light sensor, color sensor and an ultrasonic sensor in the process. Any programming/Coding ideas of how i should start? This is the maze...
  15. A

    MATLAB Could you check (if statment block) in my MATLAB code please?

    function RunlogisticOscilnumericalfisherfixedn0omega omega=1; N0=1; k = 10; A = 1; p0 = 0.1; tspan=(0:0.1:4); [t,p] = ode45(@logisticOscilnumerical,tspan,p0,[],omega,k,N0); figure(1) plot(t,p) xlabel('Time') ylabel('p') P = @(T) interp1(t,p,T); f = @(t) ( ( A.*( ( N0.*...
  16. A

    MATLAB MATLAB code for Computational Fluid Mechanics

    Hello guys, I'm writing to get some help on an exercise I've been thinking but I can't get to solve. I have to write the code for the Example 8.5 of the book White, Fluid Mechanics. Here is the problem and the solution I have to obtain. It is about one duct that has three sections in which I...
  17. mesa

    Trouble with understanding MatLab code

    Homework Statement A = [1 3; 2 4]; %Okay, so we are starting with this matrix N = 2; %Here we are setting N equal to '2' for k = 1:N %So here we have a 'for loop' for variable 'k' starting at 1 in increments of '1' up to 'N', which %happens to be '2' so once this function gets to '2' it...
  18. gfd43tg

    Triple redundancy sensor matlab code

    Homework Statement Hardware redundancy is important in many real-world engineering systems. Specifically, installing multiple sensors that measure the same quantity provides a level of safety in the event that one instrument fails during the mission lifetime. You do not want an expensive...
  19. H

    MATLAB Composite Simpsons 1/3 matlab code

    hey guys, So I'm working on a MATLAB function that uses simpsons 1/3 rule to find an integral. This is what I have done so far, but I'm not 100% confident.. I seem to get double when I use greater segments. If anyone would be able to have a look at give me some tips that would be very much...
  20. E

    MATLAB Need MATLAB Implementation for OFDM Communication Systems in Continuous-Time?

    Hello all, Does it occur that anyone here working on OFDM communication systems? I need a MATLAB implementation of such systems in the continuous time. I will provide the math derivations if requested. Thanks
  21. E

    MATLAB Matlab Code for Time-Frequency Transformation

    Hello everyone. Sorry if the question is silly, but in really need to know something. We know that The Fourier transform of time is frequency and the inverse of frequency is time. In Matlab can anyone tell me how to write it ? Because in the book Non linear fiber optics by Agrawal we found that...
  22. B

    MATLAB Help with MATLAB code; discrepancy between graph max and Matlab's max

    Hi, For some reason, when I run this MATLAB code, I'm getting what looks like about 10,000 for Rf for the largest Vo on the graph, but MATLAB is giving me Rf at (Vo)max as 100,001 Any ideas? clc; clear; close all; syms Rf Rf = 0:0.1:100000; VRt25 = 18.*(10000)./(10000 + Rf)...
  23. J

    MATLAB MatLab code for these Integrals.

    How can I write proper language for these integrals in MatLab ? Your helps really appreciated. John Mark
  24. 1

    MATLAB Plotting Beam Emittance with MATLAB Code

    Hi, I want to write a very simple code to plot the beam emittance knowing x,y,z and vx,vy,vz of each particle. I have generated with a tracking code a very simple beam (cone distribution with 1° divergence) and I want to compare the emittance of this beam with the one calculated by a...
  25. E

    MATLAB Solve Matlab Code Problem: Nonlinear Fiber Optics

    I took this code from the agrawal book: nonlinear fiber optics and I wanted to see the results : %---specify input parameters clear all; distance= input('enter fiber length (in units of L_D)= '); beta2=input(' dispersion: 1 for normal, -1 for anomalous'); N=input('Nonlinear parameter N=')...
  26. G

    MATLAB code for generating PPM :

    Hi all, I am quite new to MATLAB . I would like some help on the following: generation of Pulse Position Modulation using a MATLAB code. thank you :)
  27. W

    How to Create MATLAB Code for Geometrical Optics Image Transformation?

    Hello all, i have frustrating task in my lab... i have to generate a code in MATLAB that will get the focal length and the object distance from the lens, i.e image (1000X1000 pixels). transfer it through the lens and, for the output it should be the result of it...
  28. B

    Matlab code for solving and plotting function x'(t) = 1 + t*sin(t*x)

    Homework Statement I am trying to solve and plot the function, x'(t) = 1 + t*sin(t*x) where x(0) = 0 and t_final = 1, in order to compare this exact solution to the approximations of Euler's and Improved Euler's Method. Can anyone help me with the code in order to solve this problem, and then...
  29. B

    MATLAB Matlab Code for solving and plotting function x'(t) = 1 + t*sin(t*x)

    Hi everyone, I am trying to solve and plot the function, x'(t) = 1 + t*sin(t*x) where x(0) = 0 and t_final = 1, in order to compare this exact solution to the approximations of Euler's and Improved Euler's Method. Can anyone help me with the code in order to solve this problem, and then plot...
  30. R

    MATLAB Matlab code for detection of location of a crack using natural frequen

    please help i have to write a MATLAB code for DETECTION OF THE LOCATION AND SIZE OF A CRACK IN STEPPED CANTILEVER BEAMS BASED ON MEASUREMENTS OF NATURAL FREQUENCIES the reference paper is DETECTION OF THE LOCATION AND SIZE OF A CRACK IN STEPPED CANTILEVER BEAMS BASED ON MEASUREMENTS OF...
  31. H

    MATLAB MATLAB code has stopped working

    A few months ago my hard drive crashed and I managed to recover the data and I tried to run some of my old programs (one solving an ODE via Newton's method. Before the crash, the error was 10^-8 after around 3 iterations, now it won't converge. It looks fine, ithe than writing the code from...
  32. S

    MATLAB code for Aldous-Broder algorithm from spanning trees of a graph

    Homework Statement Let G = (V,E) be a graph with vertices V and edge set E. Aldous-Broder algorithm: Input: G = (V,E) Output: T = (V, W), where W is a subset of E such that T is a spanning tree of G. Let W be the empty set. Add edges to W in the following manner: starting at any...
  33. thekey

    MATLAB Please I need a Help with matlab code (Controlling the LEGO NXT Using MatLab)

    Hi Controlling the LEGO NXT Using MatLab What are my mistakes in this code ??! COM_CloseNXT all clc clear handle = COM_OpenNXT(); COM_SetDefaultNXT(handle); COM_CloseNXT(handle); NXT_GetBatteryLevel(handle); COM_CloseNXT(handle); COM_CloseNXT all clc clear...
  34. R

    MATLAB What is the error in running Newton's Method in Matlab for a specific function?

    I've been using this for a Newton Approximation in Matlab function x = Newton(f, fp, x, nmax, e) % f is an inline function which we apply Newton's method on % fp is an inline function that is the derivative of function f % x is the initial guess of the root % nmax is the total number...
  35. E

    MATLAB Where is my mistake in this MATLAB code?

    Hi, I am trying to plot the AN product sec II.C in the attached paper as: clear all clc s=0.5; w=0; d=5; f=0:20; NdB1=(17-30.*log10(f)); N1=10.^(NdB1./10); NdB2=40+20*(s-0.5)+26.*log10(f)-60.*log10(f+0.03); N2=10.^(NdB2./10); NdB3=50+7.5*w^0.5+20.*log10(f)-40.*log10(f+0.4)...
  36. M

    MATLAB Matlab code natural numbers subset

    I have array of natural numbers from 1 to n. They are divided into m groups, where m*(m-1)=n. I need all m-1 elements from first group, last m-2 elements from second group, last m-3 elements from third group...zero elements from last group. For example 5*4=20: 1,2,3,4; 5,6,7,8...
  37. F

    MATLAB Need help with matlab code for Newton-raphson ( really bad)

    The code runs but I get the wrong answers can you take a look at the code for this . ANSWERS ****************** x(1) = 1.035 x(2) = 1.086 x(3) = 0.927 ****************** clc clear F = @(x) [15*x(1)+(x(2)^2)-4*x(3)-13;... (x(1)^2)+10*x(2)^2-x(3)-11...
  38. F

    MATLAB Need help with Matlab code for gauss siedel i get errors, need imediat help

    Please I need HELP IMEDIATLY This is the error message that i get ? Error using ==> gauss_sied Too many input arguments. Error in ==> HW_14 at 23 [x_wo, cnt, x_w,cntt] = gauss_sied(xo, A, b, es, lam); clc clearC = [-8 1 -2 -20 2 -6 -1 -38 -3 -1 7 -34]; A = C(:,1:end-1); b = C(:,end);nr =...
  39. H

    MATLAB Matlab code for 2D inverse Fourier transforms

    I have written some routines that compute the 2D inverse Fourier transform, if anyone thinks that this may be useful at all then please let me know and I will gladly post the code.
  40. D

    MATLAB Altering Matlab Code for a Logistic Map Cobweb Plot

    I found some Matlab code that works. However, I am not sure how to alter it for my needs. How can I make the code work for this:##N_{t+1} = \frac{(1+r)N_t}{1+rN_t}##What needs to be changed? %%% MAKES A COBWEB PLOT FOR A LOGISTIC MAP % compute trajectory a=3.0; % parameter x0=0.2...
  41. F

    What is wrong with this matlab code?

    Write a user-defined MATLAB function for the following math function: y(t) = -0.2x^4 + e^(-0.5x)*x^3+7x^2 The input to the function is x and the output is y. Write the function such that x can be a vector Use this function to make a plot of the function y(x) -3≤x≤4 function y=chp7one(x)...
  42. A

    MATLAB Help with writing a matlab code

    ?hi, im trying to write a code that should do this- create a random sized zeros vector create a random size ones vector i have to do this several times and combine it all(by that order) into one vector that should lookz like- 0000011111001111001... does anybosy have an idea how to do it...
  43. M

    MATLAB Matlab code used for vehicle dynamics

    Please help me recognize what is wrong with this professor supplied code... clear all options=odeset('events', @events_passing) [t,z]=ode45(@passing,[0,10],[0,50*88/60],options) plot(t,z) function [value,isterminal,direction]=events_passing(t,z) value=z(2)-88; isterminal=1...
  44. R

    MATLAB Problem regarding Matlab code for n no of quantum well

    I have written a code which is something like that clc X = input('Molefraction of Al in system:'); n=input('no of well:'); width=zeros(1,50); for j=1:(2*n+1) width(j,:)=input('length of areas:'); end del_eg=1.247*X; V1=0.6*del_eg; V=zeros(1,100); for j=1:n...
  45. G

    MATLAB How to write Matlab code for a multivariate Beta distribution

    Hello, I am working on a problem in which I first sample two unknown probabilities, p and q, from Beta distributions, and then I want to sample both of them at the same time from a multivariate Beta distribution. This is the code that I have for sampling p and q individually from Beta...
  46. R

    MATLAB Improve Matlab Code Performance for Insulated Bar Internal Temperatures

    This code calculates the internal temperatures of an insulated bar with left and right side boundary conditions of 350 K. The initial temperature of the bar is 250. This is not part of the assignment, but I want to get in the habit of optimizing my code. Is there any way to further improve the...
  47. matt_crouch

    Matlab code fitting a line to a histogram

    Im analyzing some data from a previous student I am trying to plot a line of best fit over the histogram and hense find the value of the coefficiants the files had to be loaded as -ascii so this is the code i have typed so far x=load('filename.mat','-ascii'); mean(x); hist(x,300) this...
  48. P

    MATLAB Understanding the @ Rule in MATLAB Code with Quad Command

    HI every one what's the @ rule in the MATLAB code? especielly when we use quad command.
  49. Z

    Matlab code using ode45 difficulty

    Homework Statement I've been trying to get this code to work: ode45(@(t,y) fallode(t,y,B), [0, tmax], [31330, 0]) Homework Equations function dy = fallode(t, y, B) % ODE function to model a fall over a large range of % altitudes, reaching up to high subsonic Mach numbers. % y(1) is...
  50. C

    MATLAB Improving Tumor Detection with Matlab: A Collaborative Approach

    Hey, I'm working on a DSP project that is using Matlab to improve the detection ratios of Computer aided Diagnosis (CAD). However the companies that are capable of doing this sort of CAD ensure that their code is not distributed. If anyone has or knows how to get a piece of code like...
Back
Top