3,130 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 to get field value from a struct as a variable in order to use in a code?

Depends on your downstream code whether this is really worth it, but simply e.g. x = yourstruct.x; y = yourstruct.y;

How to get field value from a struct as a variable in order to use in a code?

Depends on your downstream code whether this is really worth it, but simply e.g. x = yourstruct.x; y = yourstruct.y;

1 day ago | 1

Answered

Attempting to have a series for sin stop summing when the precision is correct

Inside the sinser function, you never set p to a vector ... it is always just a scalar. If you want to return all of those inte...

Attempting to have a series for sin stop summing when the precision is correct

Inside the sinser function, you never set p to a vector ... it is always just a scalar. If you want to return all of those inte...

1 day ago | 0

Answered

generate unit vectors based on matrix size

Why not just V(1,2) = 1; Or if you really need to explicitly set those 0’s then start with V(:,2) = 0; followed by the above...

generate unit vectors based on matrix size

Why not just V(1,2) = 1; Or if you really need to explicitly set those 0’s then start with V(:,2) = 0; followed by the above...

3 days ago | 0

Answered

mod gives incorrect result

See this thread: https://www.mathworks.com/matlabcentral/answers/338182-how-to-get-mod-of-large-numbers

mod gives incorrect result

See this thread: https://www.mathworks.com/matlabcentral/answers/338182-how-to-get-mod-of-large-numbers

3 days ago | 1

| accepted

Answered

eulers improved method code error

s2=F(x+h/2,y+h*s1/2); %% is it correct for modified euler If "Improved" Euler's Method means "Modified" Euler's Method as your ...

eulers improved method code error

s2=F(x+h/2,y+h*s1/2); %% is it correct for modified euler If "Improved" Euler's Method means "Modified" Euler's Method as your ...

3 days ago | 1

Answered

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. What does this mean?

Look at this line: Segment(n_start)=data(n_start:(n_start+ window_size-1)); and simply plug in the numbers for the first itera...

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. What does this mean?

Look at this line: Segment(n_start)=data(n_start:(n_start+ window_size-1)); and simply plug in the numbers for the first itera...

3 days ago | 1

Answered

Getting an error with the ODE45 function.

You've got your calling code mixed in with your derivative code. You need to code this differently. E.g., one way: In a file c...

Getting an error with the ODE45 function.

You've got your calling code mixed in with your derivative code. You need to code this differently. E.g., one way: In a file c...

4 days ago | 0

| accepted

Answered

Runge Kutta method computational cost

Side Note, You should not be calculating f(x(k),t(k)) twice in your 2nd order method. You should be doing it like your 4th orde...

Runge Kutta method computational cost

Side Note, You should not be calculating f(x(k),t(k)) twice in your 2nd order method. You should be doing it like your 4th orde...

7 days ago | 1

Answered

Mex -largeArrayDims in Linux

You didn't give it the LAPACK library to link to, so there is no dgesv_ function, hence the error. You need to take this: lapac...

Mex -largeArrayDims in Linux

You didn't give it the LAPACK library to link to, so there is no dgesv_ function, hence the error. You need to take this: lapac...

7 days ago | 0

Answered

Can MEX BLAS library be used for native double matrix in C?

Two problems: 2D matrices are stored column-wise by MATLAB and is assumed by the BLAS and LAPACK routines also. So this: ...

Can MEX BLAS library be used for native double matrix in C?

Two problems: 2D matrices are stored column-wise by MATLAB and is assumed by the BLAS and LAPACK routines also. So this: ...

8 days ago | 1

| accepted

Answered

How to save ode45 outputs in a loop?

Don't use a loop. Just call ode45 once and it will give you the entire results in T and Y. [T,Y] = ode45(dydt, t, [y0, dy0]); ...

How to save ode45 outputs in a loop?

Don't use a loop. Just call ode45 once and it will give you the entire results in T and Y. [T,Y] = ode45(dydt, t, [y0, dy0]); ...

9 days ago | 0

Answered

Creating vectors by rand() and looping it

Good start, but do this to save the ceil function result back into vector: vector = ceil(vector); For the next part you need a...

Creating vectors by rand() and looping it

Good start, but do this to save the ceil function result back into vector: vector = ceil(vector); For the next part you need a...

15 days ago | 0

| accepted

Answered

How do I pull a value out of a different equation @ a specific value

[Tmin,k] = min(T); Dt = D(k);

How do I pull a value out of a different equation @ a specific value

[Tmin,k] = min(T); Dt = D(k);

15 days ago | 0

| accepted

Answered

Multiplying every secound element in a vector with -1

Or yet another of the zillion ways vny = v; vny(2:2:end) = -vny(2:2:end);

Multiplying every secound element in a vector with -1

Or yet another of the zillion ways vny = v; vny(2:2:end) = -vny(2:2:end);

15 days ago | 1

Answered

How to call all arrays that start with the name "CV_"?

Don't do that. See this post for reasons why: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-sh...

How to call all arrays that start with the name "CV_"?

Don't do that. See this post for reasons why: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-sh...

16 days ago | 0

Answered

Trying to create a simple function Matlab gives me an error message

Put your vecout( ) function code in a separate file called vecout.m

Trying to create a simple function Matlab gives me an error message

Put your vecout( ) function code in a separate file called vecout.m

16 days ago | 0

Answered

Hi guys, help me, please!

MATLAB indexing is 1-based, not 0-based. You will need to adjust your indexing: a(1) = 1; a(2) = 0; : etc

Hi guys, help me, please!

MATLAB indexing is 1-based, not 0-based. You will need to adjust your indexing: a(1) = 1; a(2) = 0; : etc

16 days ago | 0

Answered

Dimensions of arrays being concatenated are not consistent.

If they are all row vectors, then I would think something like this: Total_No_cells_r = [Total_No_cells_r, total_cellcount_r]; ...

Dimensions of arrays being concatenated are not consistent.

If they are all row vectors, then I would think something like this: Total_No_cells_r = [Total_No_cells_r, total_cellcount_r]; ...

16 days ago | 0

Answered

Extract integer number from a cell array.

You could do this: C = your cell array of strings, some containing numbers d = str2double(C); d = d(~isnan(d));

Extract integer number from a cell array.

You could do this: C = your cell array of strings, some containing numbers d = str2double(C); d = d(~isnan(d));

17 days ago | 0

Answered

Why is the inv function not working in this code (simple)

Best to put commas in your matrix difinition so that the parser doesn't inadvertently combine things that you didn't want. E.g.,...

Why is the inv function not working in this code (simple)

Best to put commas in your matrix difinition so that the parser doesn't inadvertently combine things that you didn't want. E.g.,...

17 days ago | 1

| accepted

Answered

(ODE45) Unable to perform assignment because the left and right sides have a different number of elements

It might be simpler to have separate files for this. Put this code (and only this code) in a file called HW4_matlab.m %% Solvi...

(ODE45) Unable to perform assignment because the left and right sides have a different number of elements

It might be simpler to have separate files for this. Put this code (and only this code) in a file called HW4_matlab.m %% Solvi...

17 days ago | 0

Answered

Precision in calculation of large digits

You need to convert to vpa first so that the factorial calculation is done with extended precision. factorial(vpa(97))

Precision in calculation of large digits

You need to convert to vpa first so that the factorial calculation is done with extended precision. factorial(vpa(97))

17 days ago | 2

Answered

Attempting to completely fill out an array(6,7) with 1's and 2's for connect4

Maybe you could explain what your code is supposed to be doing. Commenting the code would be great. But if you just want a boa...

Attempting to completely fill out an array(6,7) with 1's and 2's for connect4

Maybe you could explain what your code is supposed to be doing. Commenting the code would be great. But if you just want a boa...

21 days ago | 0

Answered

not enough argument input

You need to put your function code into a file called dew_point.m Then you need to call your function with inputs, e.g. T = so...

not enough argument input

You need to put your function code into a file called dew_point.m Then you need to call your function with inputs, e.g. T = so...

21 days ago | 1

Answered

Can someone help me Create a function called that will automatically generate an array where the elements in the array are the sum of the indices? i am lost on this.

If I understand your description correctly, the magic( ) function has nothing to do with your assignment. You are simply asked t...

Can someone help me Create a function called that will automatically generate an array where the elements in the array are the sum of the indices? i am lost on this.

If I understand your description correctly, the magic( ) function has nothing to do with your assignment. You are simply asked t...

21 days ago | 1

| accepted

Answered

Data arithmatic addition with single precision

Floating point operations will often yield slightly different results if you change the order of operations. This is to be expec...

Data arithmatic addition with single precision

Floating point operations will often yield slightly different results if you change the order of operations. This is to be expec...

22 days ago | 0

Answered

How to locate the index of the maximum value in a given range

Use the 2nd output of the max function: [p,i] = max(y); p is the max value, i is the index of the max value t(i) is the value...

How to locate the index of the maximum value in a given range

Use the 2nd output of the max function: [p,i] = max(y); p is the max value, i is the index of the max value t(i) is the value...

22 days ago | 0

| accepted

Answered

Change all elements in 2nd column to 3

vArr(:,2) = _____; % <-- you fill in the blank

Change all elements in 2nd column to 3

vArr(:,2) = _____; % <-- you fill in the blank

22 days ago | 0

Answered

Create array Arr with 5 rows and 4 columns with each element = 5

Yes. Replace all of your numbers with 5 and you will have it. E.g., Arr = [5 5 5 5; etc. This is the hardest way to accomplish...

Create array Arr with 5 rows and 4 columns with each element = 5

Yes. Replace all of your numbers with 5 and you will have it. E.g., Arr = [5 5 5 5; etc. This is the hardest way to accomplish...

22 days ago | 0