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)...
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...
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)...
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) -...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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
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...
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)...
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...
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=')...
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...
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...
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...
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...
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...
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...
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...
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...
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)...
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...
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...
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 =...
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.
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...
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)...
?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...
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...
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...
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...
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...
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...
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...
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...