Answered
Cannot fit this function sqrt((xs)^2+(ys)^2)-sqrt((xs-.65*cos(x))^2+(ys-.65*sin(x))^2)
Hello Guillermo, This isn't the answer you are looking for, but I don't believe a solution is possible. It is not hard to sh...

9 years ago | 1

| accepted

Answered
I have a problem interpreting reshape with a matrix product
Hello Simone, state = reshape(Psi0,n,n); % Psi0 is n^2 x 1 column vector ...

9 years ago | 2

| accepted

Answered
How to index time interval more efficiently?
Hi balandong, Here is one way to accomplish this. At present the function in the script below has no semicolons at the end o...

9 years ago | 1

| accepted

Answered
how to do fft to a gaussian function
Hello Shijie, This is happening because of basic behavior of ffts. For an N-point fft, suppose f(k) is the fourier transform...

9 years ago | 0

Answered
How do I vectorize the following the summation?
Hi Cache, To obtain G, the sum over the row index i of matrix x leads to the product G = x.'*x as you determined. ...

9 years ago | 3

| accepted

Answered
Circle in a matrix
Hi Melissa, Here is a fairly simple method that makes a softer edge by adding up contributions from the point itself and its ...

9 years ago | 2

| accepted

Answered
I wish to get the spectrum (Magnitude vs Frequency(Hz)) of a pure tone(1 kHz). However, the piece of code I'm employing to do so isn't working. What am I doing wrong?
Hello Komal, The whole point of using fftshift is to put zero frequency at the center of the resulting frequency array. If y...

9 years ago | 0

| accepted

Answered
Optimize RAM cost by only storing upper triangular part of a symmetric matrix?
Hello Xh Du, The upside here is that if you have several square upper triangular matrices of the same size, you can efficient...

9 years ago | 0

Answered
Surf Plot using loops- Z must be a matrix, not a scalar or vector.
Hi Fabricio, the z vector does not survive (except for its last value) after the for loop. z is a scalar at that point. So yo...

9 years ago | 0

| accepted

Answered
Plot the vector field of a first order ODE
Hi Tanja, Since the exponetial function creates such a wide range of values, I like your idea in the second code of plotting un...

9 years ago | 0

Answered
divide matrix into equal parts of 7 columns
Hi soepblik, Is the first piece entries 1:7 in your matrix, the second piece entries 8:14, etc? If that's not the case then ...

9 years ago | 0

Answered
Find out indexes of zeroed elements in matrix
Hi lucksBi, the find command gives you the row and column indices for a given condition. The find command searches column by co...

9 years ago | 0

| accepted

Answered
Interpolating a function that is constant over some parts of its domain?
Hi Jonathan, just swap inputs, interp1([-10,0,1,10], [0,0,1,1], x)

9 years ago | 0

| accepted

Answered
explain sparse convolution algorithm
Hi Robert, Since the posted code is oriented toward sparse matrices, it uses ‘find’ to eliminate the calculation for zeros co...

9 years ago | 0

Answered
Null space vs eigenvectors
Hi Jeff, Since your eigenvalues are all distinct, what you have is basically correct. It's just that the eigenvector and the n...

9 years ago | 1

| accepted

Answered
Hysteresis Calculation of force profile
Hi Eric, yes that is correct, the negative sign is because the x coordinate is decreasing for IntegralRet. So all you need d...

9 years ago | 0

Answered
Multiplying columns in a martrix by different values
Hi Eric, A(:,1) = A(:,1)*1e6 and similarly for the other one.

9 years ago | 0

| accepted

Answered
how to generate true random number
Hello, hu yes, Matlab random numbers are not truly random, but they are a very good simulation. The results you are seeing w...

9 years ago | 0

Answered
Need help using Matlab for an approximation of Pi via the Mandelbrot set.
Hello Lauren, For all but your second question, the reasons are because if c = 1/4 + eps and there are n steps to get past 2,...

9 years ago | 1

| accepted

Answered
Euler totient function of number
Hi Mohsin, try N = 48; % for example n = 1:N-1; ind = gcd(n,N)==1; tot = n(ind) % check ...

9 years ago | 0

| accepted

Answered
where can I download durer.mat ?
Hi John, on my pc, >> which durer.mat C:\Program Files\MATLAB\R2016b\toolbox\matlab\demos\durer.mat so despite count...

9 years ago | 2

| accepted

Answered
Simple question: How to setup Matlab to calculate more precisely?
Hi Manuela, you have just discovered one of the features of floating point arithmetic. Matlab uses 64 memory bits for a floati...

9 years ago | 0

Answered
Phase of 2D Gaussian Fourier Transform
Hello vittorio, all you need do is replace fz=fft2(z); with fz=fft2(ifftshift(z)); This is because in each dim...

9 years ago | 0

| accepted

Answered
Is there an easy (automated) way to determine if vertices are 'mutually adjacent' in a directed graph?
Hello Michael, what form is your data in? If it is the usual adjacency matrix A containing ones and zeros, with zeros on the d...

9 years ago | 0

Answered
How can I fit a second Fourier component to a polar histogram?
Hi Eric, see how this works. I added an adjustable tilt angle to the random data to test the fit. The code compares the fit t...

9 years ago | 0

Answered
Dipole antenna far-field pattern
Hi Vinci, power is proportional to the square of the electric field, so if you use E2 = abs((cos(B*L/2*cos(t))-cos(B*L/2))...

9 years ago | 2

| accepted

Answered
how to mesh a surface without interpolation of 3D points?
Hi shayan, the patch command may be what you are looking for. The following is a demo and could certainly be improved on codew...

9 years ago | 0

Answered
How can I calculate the angle between two surfaces?
Hi Tobias, You get the components of the unit normals with [nx ny nz] = surfnorm(x,y,z) so if you have two surfaces z1 and z2, ...

9 years ago | 0

Answered
Solving Matrix elements by using while iteration in Matlab
Hello nut, I suppose you could figure a convoluted way to use a while loop if you dreamed up some iterative process and stopped...

9 years ago | 1

| accepted

Answered
What is the Fourier transform of an Airy Disc?
[modified answer] Hi elham, The Fourier transform of the Airy intensity pattern is the autocorrelation of the aperture disks...

9 years ago | 0

Load more