43,353 total contributions since 2011

I do not do free private consulting. If you want to bring my attention to something, send a link to the MATLAB Answers location.

Answered

How to convert matrix indexes to cartesian coordinates

Matrices are just arrays of values and there is no inherent Cartesian coordinates associated with them. They have rows and colum...

How to convert matrix indexes to cartesian coordinates

Matrices are just arrays of values and there is no inherent Cartesian coordinates associated with them. They have rows and colum...

약 2시간 ago | 0

Answered

interp1 for matrix

No you should use interp2 for this. The value to look up depends on two factors, depth and time, but interp1 would only take one...

interp1 for matrix

No you should use interp2 for this. The value to look up depends on two factors, depth and time, but interp1 would only take one...

약 2시간 ago | 0

Answered

cannot receive udp packet

This is what you asked for. You deliberately configured udp to read across datagram boundaries until it sees a termination chara...

cannot receive udp packet

This is what you asked for. You deliberately configured udp to read across datagram boundaries until it sees a termination chara...

약 2시간 ago | 0

Answered

Hi, I am trying to obtain accelerometer data from a GY-521 board through solely matlab, rather than using arduino code. I am a beginner to I2C and arduino, and would appreciate some help in obtaining this data. Many thanks.

This is not typically possible. Most systems do not have i2c connectors directly available. MS Windows does support the possi...

Hi, I am trying to obtain accelerometer data from a GY-521 board through solely matlab, rather than using arduino code. I am a beginner to I2C and arduino, and would appreciate some help in obtaining this data. Many thanks.

This is not typically possible. Most systems do not have i2c connectors directly available. MS Windows does support the possi...

약 3시간 ago | 0

Answered

Error "using symengine>@()0.0" in ODE Solver

When you call matlabFunction pass 'vars', r

Error "using symengine>@()0.0" in ODE Solver

When you call matlabFunction pass 'vars', r

약 3시간 ago | 0

Answered

fminsearch of the sum of an array of anonymous functions with two inputs?

z1 = @(par) (log(RO)-log(par(1)))*par(2); so z1 is defined with one argument. L_W_temp{i} = @(par) -e(z1(par(1),par(2))); ...

fminsearch of the sum of an array of anonymous functions with two inputs?

z1 = @(par) (log(RO)-log(par(1)))*par(2); so z1 is defined with one argument. L_W_temp{i} = @(par) -e(z1(par(1),par(2))); ...

약 7시간 ago | 1

Answered

How to get the longest consecutive values in a column vector and the position at which it starts

https://www.mathworks.com/matlabcentral/fileexchange/41813-runlength

How to get the longest consecutive values in a column vector and the position at which it starts

https://www.mathworks.com/matlabcentral/fileexchange/41813-runlength

약 16시간 ago | 0

Answered

I want the code to randomize the rows and present each row for 10 times

Decentration = [0, 0.5; 0, 0; 0, -0.5; -0.5,0; 0.5, 0]; trial = 10; n = size(Decentration, 1); idx = repmat(1:n, 1, trial); ...

I want the code to randomize the rows and present each row for 10 times

Decentration = [0, 0.5; 0, 0; 0, -0.5; -0.5,0; 0.5, 0]; trial = 10; n = size(Decentration, 1); idx = repmat(1:n, 1, trial); ...

약 17시간 ago | 1

Answered

How can i use the ceil function rightly?

>> 2.7/0.3 - 9 ans = 1.77635683940025e-15 so ceil() is correct. As to why 2.7/0.3 is not exactly 9, see http://mat...

How can i use the ceil function rightly?

>> 2.7/0.3 - 9 ans = 1.77635683940025e-15 so ceil() is correct. As to why 2.7/0.3 is not exactly 9, see http://mat...

약 17시간 ago | 0

Answered

quenstion about uiload in matlab

The uiload call is going to prompt the user to select a file, and then it is going to guide the user to import variables from th...

quenstion about uiload in matlab

The uiload call is going to prompt the user to select a file, and then it is going to guide the user to import variables from th...

약 18시간 ago | 0

Answered

Time reading in matlab

%set up opt = detectImportOptions('1932.catalog', 'FileType', 'text', 'readvariablenames', false, 'HeaderLines', 10); opt = se...

Time reading in matlab

%set up opt = detectImportOptions('1932.catalog', 'FileType', 'text', 'readvariablenames', false, 'HeaderLines', 10); opt = se...

약 19시간 ago | 0

Answered

Help in creating function , built in equation

syms x y; eqns = damontwo(x,y); solve(eqns) %% function function yin = damontwo(x,y) yin(1) = input('Enter first equ...

Help in creating function , built in equation

syms x y; eqns = damontwo(x,y); solve(eqns) %% function function yin = damontwo(x,y) yin(1) = input('Enter first equ...

1일 ago | 0

Answered

Problem with indefinite integral

https://www.mathworks.com/help/symbolic/int.html#btydjvs-2 TIPS Results returned by int do not include integration constants....

Problem with indefinite integral

https://www.mathworks.com/help/symbolic/int.html#btydjvs-2 TIPS Results returned by int do not include integration constants....

1일 ago | 0

Answered

Initial guess Error using fsolve

NZ = @(a,b) a ./ (b + (a==0 & b == 0)); myfun=@(y) exp(-s2^2./2).*exp(y*s2).*NZ(1-qfunc((t1(i)-s1-rho*y+rho*s2)./sqrt(1-rho^2))...

Initial guess Error using fsolve

NZ = @(a,b) a ./ (b + (a==0 & b == 0)); myfun=@(y) exp(-s2^2./2).*exp(y*s2).*NZ(1-qfunc((t1(i)-s1-rho*y+rho*s2)./sqrt(1-rho^2))...

1일 ago | 1

| accepted

Answered

XMAX must be a floating point scalar in double integral. Kindly help.

ai=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s Notice the colon operators. Your ai is going to be a vector. Like...

XMAX must be a floating point scalar in double integral. Kindly help.

ai=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s Notice the colon operators. Your ai is going to be a vector. Like...

1일 ago | 0

| accepted

Answered

Only getting the last iteration from for loop?

ar0 = zeros(100,n); int = zeros(100,n); Okay, looks like you want to create outputs named ar0 and int for r = 1:n int = fd0....

Only getting the last iteration from for loop?

ar0 = zeros(100,n); int = zeros(100,n); Okay, looks like you want to create outputs named ar0 and int for r = 1:n int = fd0....

1일 ago | 0

| accepted

Answered

using solve for solving self and mutual inductance of a pmsm

Using a different programming package, I find that the solution is Lm is anything positive Pi = pi in the below w = (50000*co...

using solve for solving self and mutual inductance of a pmsm

Using a different programming package, I find that the solution is Lm is anything positive Pi = pi in the below w = (50000*co...

1일 ago | 0

Answered

Solving Inequalities greater than and smaller than at the same time

In sufficiently recent versions you can code solve(-15< 10*S < 15, S) However this is not documented and not recommended. It i...

Solving Inequalities greater than and smaller than at the same time

In sufficiently recent versions you can code solve(-15< 10*S < 15, S) However this is not documented and not recommended. It i...

1일 ago | 0

| accepted

Answered

. Find a MATLAB built in function that is used to find the lowest common denominator of fractions.

[n1, d1] = rat(1/4); [n2, d2] = rat(1/10); com = lcm(d1, d2); Now that you have the least common multple of the denominators,...

. Find a MATLAB built in function that is used to find the lowest common denominator of fractions.

[n1, d1] = rat(1/4); [n2, d2] = rat(1/10); com = lcm(d1, d2); Now that you have the least common multple of the denominators,...

1일 ago | 0

Answered

How to catch the error thrown when unable to connect to an arduino?

>> try; arduino("/dev/cu.Bluetooth-Incoming-Port"); catch ME; disp('nan nan nah'); end nan nan nah The particular exception is...

How to catch the error thrown when unable to connect to an arduino?

>> try; arduino("/dev/cu.Bluetooth-Incoming-Port"); catch ME; disp('nan nan nah'); end nan nan nah The particular exception is...

2일 ago | 0

| accepted

Answered

How to crop specific portion of a grayscale image?

img = imread('gray4.jpg'); im = imclearborder(255-imclearborder(255-rgb2gray(img)));imshow(im); hc = sum(im,2); mask = hc >= ...

How to crop specific portion of a grayscale image?

img = imread('gray4.jpg'); im = imclearborder(255-imclearborder(255-rgb2gray(img)));imshow(im); hc = sum(im,2); mask = hc >= ...

2일 ago | 0

| accepted

Answered

MOD for optimization variable

Introduce an extra integer variable and constrain equality x-3*extra = 1

MOD for optimization variable

Introduce an extra integer variable and constrain equality x-3*extra = 1

2일 ago | 0

Answered

how to make data packets from digital signals

https://www.mathworks.com/help/dsp/ref/buffer.html

how to make data packets from digital signals

https://www.mathworks.com/help/dsp/ref/buffer.html

2일 ago | 0

Answered

how can I compare the length of two arrays?

You can look at length() However, you need to be careful about how you define length of an array. How does the length of 1 2 ...

how can I compare the length of two arrays?

You can look at length() However, you need to be careful about how you define length of an array. How does the length of 1 2 ...

3일 ago | 0

Answered

How to calculate average intensity of the image given in the form of a matrix?

mean2(TheArray)

How to calculate average intensity of the image given in the form of a matrix?

mean2(TheArray)

3일 ago | 1

| accepted

Answered

Recording sound while acquiring data from pressure sensor that connected with arduino

You would use record(), which will permit you to continue running. You would set up a recording duration ahead of time. However...

Recording sound while acquiring data from pressure sensor that connected with arduino

You would use record(), which will permit you to continue running. You would set up a recording duration ahead of time. However...

3일 ago | 0

Answered

generate odd and even numbers from randn function in simulink

https://www.mathworks.com/help/dsp/ref/convert1dto2d.html -- reshape the vector to two rows https://www.mathworks.com/help/dsp/...

generate odd and even numbers from randn function in simulink

https://www.mathworks.com/help/dsp/ref/convert1dto2d.html -- reshape the vector to two rows https://www.mathworks.com/help/dsp/...

4일 ago | 0

Answered

How would I create a script to read files line-by-line to save memory

vary_every = 10000; expected_buffers = 10000; %1000000000 / 100000 group_every = 360; variances = zeros(1, expected_buffers...

How would I create a script to read files line-by-line to save memory

vary_every = 10000; expected_buffers = 10000; %1000000000 / 100000 group_every = 360; variances = zeros(1, expected_buffers...

4일 ago | 0

Answered

Translating sigma notation / summation / series and integral equation from Microsoft Word into MATLAB syntax and graphing / plotting

syms n t Q = @(v) sym(v); %convert to rational Pi = sym('pi'); f1 = Q(0.111627907); f2a = int((Q(-0.3072*10^(-5))*(t ...

Translating sigma notation / summation / series and integral equation from Microsoft Word into MATLAB syntax and graphing / plotting

syms n t Q = @(v) sym(v); %convert to rational Pi = sym('pi'); f1 = Q(0.111627907); f2a = int((Q(-0.3072*10^(-5))*(t ...

4일 ago | 2

Answered

Why can't 32-bit values be converted to 24-bit values?

MATLAB does not have any 24 bit data type. typecast() is only for taking a block of memory and changing the interpretation of ...

Why can't 32-bit values be converted to 24-bit values?

MATLAB does not have any 24 bit data type. typecast() is only for taking a block of memory and changing the interpretation of ...

4일 ago | 1

| accepted