3 065 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

Is there a matlab function similar to numpy.spacing

From the numpy.spacing doc: "It can be considered as a generalization of EPS ... there should not be any representable number ...

Is there a matlab function similar to numpy.spacing

From the numpy.spacing doc: "It can be considered as a generalization of EPS ... there should not be any representable number ...

ungefär 17 timmar ago | 3

Answered

What is the best way to insure that all of my functions are using the same constant values?

I use a function that returns a structure, containing the values and the unit descriptions. Your code can either pass this stru...

What is the best way to insure that all of my functions are using the same constant values?

I use a function that returns a structure, containing the values and the unit descriptions. Your code can either pass this stru...

ungefär 19 timmar ago | 3

Answered

Separate out every fourth element of a Vector

V = your vector result = V; result(4:4:end) = []; % remove every 4th element The above syntax with [] on the rhs is special ...

Separate out every fourth element of a Vector

V = your vector result = V; result(4:4:end) = []; % remove every 4th element The above syntax with [] on the rhs is special ...

5 dagar ago | 0

| accepted

Answered

How to extract the value of dydt from ode45 function

Why can't you just call your odefcn( ) function with your solution t and xSol vector elements as inputs (e.g., in a loop)? Does...

How to extract the value of dydt from ode45 function

Why can't you just call your odefcn( ) function with your solution t and xSol vector elements as inputs (e.g., in a loop)? Does...

5 dagar ago | 1

| accepted

Answered

How to make an assignment for my for loop?

This syntax with the curly braces next to SBOS means it is a cell array: SBOB{ whatever } But this syntax with the dot notatio...

How to make an assignment for my for loop?

This syntax with the curly braces next to SBOS means it is a cell array: SBOB{ whatever } But this syntax with the dot notatio...

5 dagar ago | 1

| accepted

Answered

Write binary file in Matlab

Can you read and write as “STREAM” in your FORTRAN compiler? No header stuff to worry about.

Write binary file in Matlab

Can you read and write as “STREAM” in your FORTRAN compiler? No header stuff to worry about.

6 dagar ago | 0

Answered

how binary floating point to real decimal number representation ?

You can't use dec2bin( ) reliably for this conversion in all versions of MATLAB because it is limited by flintmax (see note at b...

how binary floating point to real decimal number representation ?

You can't use dec2bin( ) reliably for this conversion in all versions of MATLAB because it is limited by flintmax (see note at b...

6 dagar ago | 0

Answered

Binary floating point Representation in Matlab

Did you try it? >> A=[ 0.1900 -0.0300 -0.1300 0 0.1500 -0.0700 0.0500 0.1600 -0.2500 -0.1900]; >> dec2bin(typecast(A,'uint...

Binary floating point Representation in Matlab

Did you try it? >> A=[ 0.1900 -0.0300 -0.1300 0 0.1500 -0.0700 0.0500 0.1600 -0.2500 -0.1900]; >> dec2bin(typecast(A,'uint...

6 dagar ago | 0

| accepted

Answered

Find sum of elements in a cell along the columns

Is this what you are trying to do? (using the curly braces) y = sum([A{2,:,1}])

Find sum of elements in a cell along the columns

Is this what you are trying to do? (using the curly braces) y = sum([A{2,:,1}])

9 dagar ago | 0

| accepted

Answered

Can somebody explain me this answer?

You are using linear indexing into "a". This matrix: >> 3*ones(2) ans = 3 3 3 3 When used as indexing, i...

Can somebody explain me this answer?

You are using linear indexing into "a". This matrix: >> 3*ones(2) ans = 3 3 3 3 When used as indexing, i...

9 dagar ago | 1

Answered

Using 3D array to subtract row Q from row P

It is unclear what you really want. If you want the Euclidean distance squared between rows, e.g., rows 1 and 3, then just d =...

Using 3D array to subtract row Q from row P

It is unclear what you really want. If you want the Euclidean distance squared between rows, e.g., rows 1 and 3, then just d =...

11 dagar ago | 0

Answered

How to change radians into degrees?

Why are you using sym to find the angle? Just use atand( ) directly with the appropriate input. That seems to be the intent of...

How to change radians into degrees?

Why are you using sym to find the angle? Just use atand( ) directly with the appropriate input. That seems to be the intent of...

12 dagar ago | 0

Answered

I assign A = B; but I could not use A and B interchangeably

You are changing I_fted inside the loop. If you subsequently use it in another calculation within the loop, it would not be surp...

I assign A = B; but I could not use A and B interchangeably

You are changing I_fted inside the loop. If you subsequently use it in another calculation within the loop, it would not be surp...

13 dagar ago | 1

| accepted

Answered

matrix dimension reshape error

To solve your sizing issues, type the following into MATLAB: dbstop if error Then run your code. When the error occurs, your c...

matrix dimension reshape error

To solve your sizing issues, type the following into MATLAB: dbstop if error Then run your code. When the error occurs, your c...

13 dagar ago | 0

Answered

Is it possible to 'clear all' variables except one?

Another method is the FEX keep utility: https://www.mathworks.com/matlabcentral/fileexchange/181-keep

Is it possible to 'clear all' variables except one?

Another method is the FEX keep utility: https://www.mathworks.com/matlabcentral/fileexchange/181-keep

13 dagar ago | 0

Answered

MKL 2018 supposedly supports integer matrix multiplication. Can this feature be added to Matlab?

The main problem with matrix multiplication on integer types (int32, etc.) in MATLAB is that the operation result is ambiguous i...

MKL 2018 supposedly supports integer matrix multiplication. Can this feature be added to Matlab?

The main problem with matrix multiplication on integer types (int32, etc.) in MATLAB is that the operation result is ambiguous i...

15 dagar ago | 0

Answered

Convert 0×1 empty double column vector to zero

Is this construct all you need? if( isempty(x) ) x = 0; end

Convert 0×1 empty double column vector to zero

Is this construct all you need? if( isempty(x) ) x = 0; end

19 dagar ago | 0

| accepted

Answered

How to use randperm with minimum spacing between random numbers

Maybe something like this will suffice for your needs? p = b * randperm(floor(n/b),k) If n/b isn't an integer value, then ther...

How to use randperm with minimum spacing between random numbers

Maybe something like this will suffice for your needs? p = b * randperm(floor(n/b),k) If n/b isn't an integer value, then ther...

19 dagar ago | 0

Answered

How do you append to a matrix within a for loop when the matrices are unequal in size?

Maybe you could use a cell array. E.g., : D1 = cell(1,N); for a=1:N : D1{a} = C; end Then the first matrix...

How do you append to a matrix within a for loop when the matrices are unequal in size?

Maybe you could use a cell array. E.g., : D1 = cell(1,N); for a=1:N : D1{a} = C; end Then the first matrix...

20 dagar ago | 1

| accepted

Answered

What is the best way to save to .csv without losing precision and with column headers?

Why are you using fprintf in a loop? Can't you do it all in one call? E.g., this for i = 1:length(x) fprintf(fid,'%f , %...

What is the best way to save to .csv without losing precision and with column headers?

Why are you using fprintf in a loop? Can't you do it all in one call? E.g., this for i = 1:length(x) fprintf(fid,'%f , %...

21 dagar ago | 0

| accepted

Answered

Error: Too many output arguments.

Your function isn't coded to return anything. Try this: function timber_length = GET_NEAREST_LENGTH(length) Btw, "length" is t...

Error: Too many output arguments.

Your function isn't coded to return anything. Try this: function timber_length = GET_NEAREST_LENGTH(length) Btw, "length" is t...

22 dagar ago | 0

| accepted

Answered

write a function to translate a 3d object

You didn't write your function to return an output. Try this: function S = shift(S,dist,axis)

write a function to translate a 3d object

You didn't write your function to return an output. Try this: function S = shift(S,dist,axis)

22 dagar ago | 1

| accepted

Answered

dlmread adds low precision digits

Any function (dlmread, fscanf, etc) in any language (MATLAB, C, etc.) reading text numbers into floating point will have this is...

dlmread adds low precision digits

Any function (dlmread, fscanf, etc) in any language (MATLAB, C, etc.) reading text numbers into floating point will have this is...

22 dagar ago | 1

| accepted

Answered

function f(x)=xe^x

Take a look at this loop from your code: for j=1:length(x) y = (1/N)*(a+((j-1)*h)); % <-- This replaces y at each step ... it ...

function f(x)=xe^x

Take a look at this loop from your code: for j=1:length(x) y = (1/N)*(a+((j-1)*h)); % <-- This replaces y at each step ... it ...

22 dagar ago | 1

Answered

Extending an order in a vector

One way: >> result = cell2mat(arrayfun(@(y)x*y-x+1:x*y,y,'uni',false)) result = 1 2 3 7 8 9 13 ...

Extending an order in a vector

One way: >> result = cell2mat(arrayfun(@(y)x*y-x+1:x*y,y,'uni',false)) result = 1 2 3 7 8 9 13 ...

23 dagar ago | 1

| accepted

Answered

How to Run filename.mexw64 in command prompt

Assuming you are on a WIN64 system, call it just like any other function. E.g., my_result = filename(my_arguments); The filena...

How to Run filename.mexw64 in command prompt

Assuming you are on a WIN64 system, call it just like any other function. E.g., my_result = filename(my_arguments); The filena...

23 dagar ago | 0

Answered

Pass pointer to scalar variable in mex function

"... The only way I've gotten around this before is by making the scalar variable into a vector and just using the first element...

Pass pointer to scalar variable in mex function

"... The only way I've gotten around this before is by making the scalar variable into a vector and just using the first element...

26 dagar ago | 0

Answered

2D summation loop

Take the denominator for instance. Literally written out, this would be denominator = 0; for k=1:K denominator = denomin...

2D summation loop

Take the denominator for instance. Literally written out, this would be denominator = 0; for k=1:K denominator = denomin...

27 dagar ago | 0

| accepted

Answered

Get a matrix by interaction

Maybe use cell arrays. E.g., BCG{gen} = horzcat (dx1, dy1, dx2, dy2, dx3, dy3, SLL); Then everywhere downstream in your code, ...

Get a matrix by interaction

Maybe use cell arrays. E.g., BCG{gen} = horzcat (dx1, dy1, dx2, dy2, dx3, dy3, SLL); Then everywhere downstream in your code, ...

28 dagar ago | 0

| accepted

Answered

Implicit expansion with empty arrays

In the 1st case, you are expanding a dimension of 1 (the 3rd dimension of the first operand) to 0, so it is scalar expansion. I...

Implicit expansion with empty arrays

In the 1st case, you are expanding a dimension of 1 (the 3rd dimension of the first operand) to 0, so it is scalar expansion. I...

28 dagar ago | 0

| accepted