2,910 total contributions since 2007

Interested in external applications, mex & engine applications with Fortran, C, C++, etc, particularly in the areas of speed improvement and memory management efficiencies.

Answered

How top stop for loop if value is reached

if( norm(X(c+1,:)-X(c,:)) < some_tolerance ) break; end or perhaps if( all(abs(X(c+1,:)-X(c,:))) < some_tolerance ) ...

How top stop for loop if value is reached

if( norm(X(c+1,:)-X(c,:)) < some_tolerance ) break; end or perhaps if( all(abs(X(c+1,:)-X(c,:))) < some_tolerance ) ...

7 hours ago | 0

| accepted

Answered

2 degrees of freedom mass-spring system

In this line dy=[y(2);y(4);dy(3);-inv(M)*K*y]; looks like M and K are both 2x2 but y is 4x1, hence the error. Also, your argu...

2 degrees of freedom mass-spring system

In this line dy=[y(2);y(4);dy(3);-inv(M)*K*y]; looks like M and K are both 2x2 but y is 4x1, hence the error. Also, your argu...

1 day ago | 0

Answered

Fourth Order Runge Kutta for Systems

This line does not have the rhs state syntax correct: y_vals(i+1,:) = y_vals(i) + (k_1+2*(k_2+k_3)+k_4)/6*h; It should be thi...

Fourth Order Runge Kutta for Systems

This line does not have the rhs state syntax correct: y_vals(i+1,:) = y_vals(i) + (k_1+2*(k_2+k_3)+k_4)/6*h; It should be thi...

1 day ago | 0

Answered

Vectorize many matrix multiplications using the third dimension

See this link: https://www.mathworks.com/matlabcentral/answers/456711-how-can-i-do-matrix-multiplication-on-sets-of-data-in-an-...

Vectorize many matrix multiplications using the third dimension

See this link: https://www.mathworks.com/matlabcentral/answers/456711-how-can-i-do-matrix-multiplication-on-sets-of-data-in-an-...

2 days ago | 1

Answered

i want to plot x and y for ODE45 function

This line doesn't look correct: dy(1) = x(2); The first agument x in the derivative function is the independent variable and a...

i want to plot x and y for ODE45 function

This line doesn't look correct: dy(1) = x(2); The first agument x in the derivative function is the independent variable and a...

2 days ago | 1

| accepted

Answered

How can I do matrix multiplication on sets of data in an array without looping?

First, some basic data storage advice. When you have multiple matrices stored in a larger matrix or array, it is usually best to...

How can I do matrix multiplication on sets of data in an array without looping?

First, some basic data storage advice. When you have multiple matrices stored in a larger matrix or array, it is usually best to...

3 days ago | 1

| accepted

Answered

Help Converting C++ to MATLAB.

Probably easiest is just to do it by hand one line at a time. Replace the control syntax with its MATLAB counterpart, and add 1...

Help Converting C++ to MATLAB.

Probably easiest is just to do it by hand one line at a time. Replace the control syntax with its MATLAB counterpart, and add 1...

4 days ago | 0

Answered

Second Order ODE with Runge Kutta 3 "K's problem"

You are using the same k's for x1 and x2, which is incorrect. That is, you are using f2( ) to calculate the k's, but these shoul...

Second Order ODE with Runge Kutta 3 "K's problem"

You are using the same k's for x1 and x2, which is incorrect. That is, you are using f2( ) to calculate the k's, but these shoul...

4 days ago | 0

| accepted

Answered

Nonscalar arrays of function handles are not allowed; use cell arrays instead error, not sure what it means / how to fix it

You are simply using the wrong syntax for what you really want. It should be something like this instead: %v[1] = x %v[2] = y...

Nonscalar arrays of function handles are not allowed; use cell arrays instead error, not sure what it means / how to fix it

You are simply using the wrong syntax for what you really want. It should be something like this instead: %v[1] = x %v[2] = y...

8 days ago | 0

Answered

What function returns (as an integer) the number of bits in a data type or class, e.g. returns 16 for 'int16' or 'uint16' variables, 32 (or whatever) for 'float' types, etc.?

I think everything that MATLAB runs on currently uses IEEE single and double floating point formats. And the signed integer for...

What function returns (as an integer) the number of bits in a data type or class, e.g. returns 16 for 'int16' or 'uint16' variables, 32 (or whatever) for 'float' types, etc.?

I think everything that MATLAB runs on currently uses IEEE single and double floating point formats. And the signed integer for...

8 days ago | 0

Answered

To Stupid for Matrix Loop

Do you mean simply this? for i=x for j=y IMG(i,j) = pixfilter(IMG,i,j); end end

To Stupid for Matrix Loop

Do you mean simply this? for i=x for j=y IMG(i,j) = pixfilter(IMG,i,j); end end

8 days ago | 0

Answered

How do i write an input statement asking the user to enter their birthdate as a matrix with entries of month,day, year?

If the user follows instructions, birthdate will be a vector of three numbers, so you need the format string to print out three ...

How do i write an input statement asking the user to enter their birthdate as a matrix with entries of month,day, year?

If the user follows instructions, birthdate will be a vector of three numbers, so you need the format string to print out three ...

9 days ago | 1

| accepted

Answered

Solving questions related to taylor series expansion

You need to compare the absolute value of the term to your tolerance. Remember, some of the terms are negative. while abs(term(...

Solving questions related to taylor series expansion

You need to compare the absolute value of the term to your tolerance. Remember, some of the terms are negative. while abs(term(...

9 days ago | 0

| accepted

Answered

Recursion for Unnesting 1x1 Cell Array

Are you sure it is a single quote char string 'example' and not a double quote string "another_example"? What is the actual err...

Recursion for Unnesting 1x1 Cell Array

Are you sure it is a single quote char string 'example' and not a double quote string "another_example"? What is the actual err...

9 days ago | 0

| accepted

Answered

sum command giving ridiculous answer

It could be you are comparing apples to oranges. The actual numbers probably have more than four digits that are not being displ...

sum command giving ridiculous answer

It could be you are comparing apples to oranges. The actual numbers probably have more than four digits that are not being displ...

9 days ago | 2

Answered

Why am I getting "Undefined function or variable" when I use an exponential in the function?

There is no "I" variable in your code. Hence the error.

Why am I getting "Undefined function or variable" when I use an exponential in the function?

There is no "I" variable in your code. Hence the error.

9 days ago | 0

Answered

Generate 500 numbers using probability density functions

r = rand(1,500); Use the r values as an indicator of which distribution f or g to draw from. For those r < 0.4, generate normal...

Generate 500 numbers using probability density functions

r = rand(1,500); Use the r values as an indicator of which distribution f or g to draw from. For those r < 0.4, generate normal...

9 days ago | 1

| accepted

Answered

Pre-locating an array

Numeric arrays must be rectangular. You cannot have different dimensions for different slices. To get that behavior you would n...

Pre-locating an array

Numeric arrays must be rectangular. You cannot have different dimensions for different slices. To get that behavior you would n...

9 days ago | 0

| accepted

Answered

How to find Matlab version to be used in the mex file header

Version info for mex routines can be found in this FEX submission: https://www.mathworks.com/matlabcentral/fileexchange/67016-c...

How to find Matlab version to be used in the mex file header

Version info for mex routines can be found in this FEX submission: https://www.mathworks.com/matlabcentral/fileexchange/67016-c...

9 days ago | 1

Answered

How do I reorder a 3D matrix in a specific way?

There's got to be a simpler way, but here goes p = permute(MeanV,[2 1 3]); result = reshape(cat(3,p(:,1,:),p(:,2,:),p(:,3,:)),...

How do I reorder a 3D matrix in a specific way?

There's got to be a simpler way, but here goes p = permute(MeanV,[2 1 3]); result = reshape(cat(3,p(:,1,:),p(:,2,:),p(:,3,:)),...

10 days ago | 0

Answered

Index exceeds matrix dimensions

You don't index wE in your loop when you are doing the iterations, so each iteration overwrites the previous iteration. Looks li...

Index exceeds matrix dimensions

You don't index wE in your loop when you are doing the iterations, so each iteration overwrites the previous iteration. Looks li...

10 days ago | 0

Answered

Column-wise inexing of matrix

One way that is scalable and matches your example: A(indx + (0:size(indx,2)-1)*size(A,1)) This uses implicit expansion. On ear...

Column-wise inexing of matrix

One way that is scalable and matches your example: A(indx + (0:size(indx,2)-1)*size(A,1)) This uses implicit expansion. On ear...

10 days ago | 1

| accepted

Answered

Multiply each column of a matrix by another matrix

Another way: C = sqrt(sum(E.*(J*E))); For the sizes involved, you probably won't see any significant timing differences betwee...

Multiply each column of a matrix by another matrix

Another way: C = sqrt(sum(E.*(J*E))); For the sizes involved, you probably won't see any significant timing differences betwee...

10 days ago | 1

| accepted

Answered

What does zeros(2,3,4) mean?

It creates a double array of dimensions 2 x 3 x 4 filled with 0's. doc zeros

What does zeros(2,3,4) mean?

It creates a double array of dimensions 2 x 3 x 4 filled with 0's. doc zeros

11 days ago | 1

Answered

Can ODE solvers produce different results when the MATLAB versions vary?

Running on 2006 version may be the only way to be sure. In general, it is not unusual to see differences in some function behav...

Can ODE solvers produce different results when the MATLAB versions vary?

Running on 2006 version may be the only way to be sure. In general, it is not unusual to see differences in some function behav...

14 days ago | 0

Answered

How to convert an array of bytes to IEEE 754 single-precision float?

Try this: >> swapbytes(typecast(uint8([65 227 216 168]),'single')) ans = single 28.4808

How to convert an array of bytes to IEEE 754 single-precision float?

Try this: >> swapbytes(typecast(uint8([65 227 216 168]),'single')) ans = single 28.4808

18 days ago | 0

| accepted

Answered

index an array with arrays

I'm still not exactly sure what you are trying to do, but If data is 1D and you want to set all values between the indexes to so...

index an array with arrays

I'm still not exactly sure what you are trying to do, but If data is 1D and you want to set all values between the indexes to so...

21 days ago | 0

| accepted

Answered

my code does not loop

You need to move your err initialization inside your loop. I.e., these lines need to move: iter=0; err=1; Also, you need to i...

my code does not loop

You need to move your err initialization inside your loop. I.e., these lines need to move: iter=0; err=1; Also, you need to i...

21 days ago | 0

| accepted