3,084 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 return the outputs of mexFunction() in Matlab?

Put this at the bottom of your code. But remember that if you call mexErrMsgTxt your mex function will exit immediately and not ...

How to return the outputs of mexFunction() in Matlab?

Put this at the bottom of your code. But remember that if you call mexErrMsgTxt your mex function will exit immediately and not ...

약 6시간 ago | 0

Answered

Error: Matrix dimensions must agree

You could use V(2:end) or V(1:end-1) instead of V in that line. Or maybe average the two.

Error: Matrix dimensions must agree

You could use V(2:end) or V(1:end-1) instead of V in that line. Or maybe average the two.

1일 ago | 0

| accepted

Answered

Write a MATLAB code to estimate the exponential function. Inputs should be x and n. The outputs must include approximate value, true value, error, absolute error, and relative error.

Put your function code for e_to_x() in a separate file called e_to_x.m somewhere on the MATLAB path. Then put your other code t...

Write a MATLAB code to estimate the exponential function. Inputs should be x and n. The outputs must include approximate value, true value, error, absolute error, and relative error.

Put your function code for e_to_x() in a separate file called e_to_x.m somewhere on the MATLAB path. Then put your other code t...

2일 ago | 0

Answered

Kindly give me the Matlab code for simplex method?

Use the MATLAB supplied function fminsearch.

Kindly give me the Matlab code for simplex method?

Use the MATLAB supplied function fminsearch.

2일 ago | 0

Answered

Error when calling the mexFunction

You probably should have gotten a warning from the compiler that your callFun( ) function doesn't return anything, even though t...

Error when calling the mexFunction

You probably should have gotten a warning from the compiler that your callFun( ) function doesn't return anything, even though t...

2일 ago | 0

| accepted

Answered

How to turn assigned vectors into a 3x3 matrix?

Assuming vec3 is a typo, result = [vec1;vec2;vec3]; If you need to, you can transpose the result. If your vec3 is not a typo,...

How to turn assigned vectors into a 3x3 matrix?

Assuming vec3 is a typo, result = [vec1;vec2;vec3]; If you need to, you can transpose the result. If your vec3 is not a typo,...

3일 ago | 0

Answered

[Create mexfunction from C code] The order of several c files

The order you compile your source code files should not matter. The error seems to be that the compiler can't find the resource...

[Create mexfunction from C code] The order of several c files

The order you compile your source code files should not matter. The error seems to be that the compiler can't find the resource...

3일 ago | 0

Answered

When I try to run a function in matlab, I get an error, it is undefined

Put this code in a file called checkEchelonMatrix.m that is on the MATLAB path: function [result] = checkEchelonMatrix(M) %res...

When I try to run a function in matlab, I get an error, it is undefined

Put this code in a file called checkEchelonMatrix.m that is on the MATLAB path: function [result] = checkEchelonMatrix(M) %res...

3일 ago | 0

| accepted

Answered

Memory erased in mex file

I would highly advise combining your multiple mex routines into one mex routine that you call with a directive (e.g., a string) ...

Memory erased in mex file

I would highly advise combining your multiple mex routines into one mex routine that you call with a directive (e.g., a string) ...

3일 ago | 0

Answered

Sort Index - Bug

The sort index gives the location in the original array of the sorted values. I.e., the sort results "a" are "original_array(sor...

Sort Index - Bug

The sort index gives the location in the original array of the sorted values. I.e., the sort results "a" are "original_array(sor...

3일 ago | 1

Answered

[Create mexfunction from C code] warning: implicit declaration of function

You call myfunction( ) before the compiler has seen a prototype or definition of myfunction( ). Either move your square( ) and ...

[Create mexfunction from C code] warning: implicit declaration of function

You call myfunction( ) before the compiler has seen a prototype or definition of myfunction( ). Either move your square( ) and ...

3일 ago | 0

| accepted

Answered

How can we create a vector of length n

There are many ways of doing this. E.g., use the ones( ) function and divide by 10. Or use the zeros( ) function and add 1/10....

How can we create a vector of length n

There are many ways of doing this. E.g., use the ones( ) function and divide by 10. Or use the zeros( ) function and add 1/10....

4일 ago | 0

| accepted

Answered

Index Exceeds Matrix Dimensions

You have inadvertantly created variables named "dot" and "cross" that are shadowing the MATLAB functions of the same names. Cha...

Index Exceeds Matrix Dimensions

You have inadvertantly created variables named "dot" and "cross" that are shadowing the MATLAB functions of the same names. Cha...

4일 ago | 0

Answered

Saving all outputs of for for-loop

Basic steps for you to take would be: Create your range up front, and not as part of the loop indexing. E.g., a t vector Use t...

Saving all outputs of for for-loop

Basic steps for you to take would be: Create your range up front, and not as part of the loop indexing. E.g., a t vector Use t...

4일 ago | 0

Answered

Create matrix indicating combinations of dummy variables

Variations of this technique are often used, but this can exceed your memory if n gets too large: n = 8; result = dec2bin(0:2^...

Create matrix indicating combinations of dummy variables

Variations of this technique are often used, but this can exceed your memory if n gets too large: n = 8; result = dec2bin(0:2^...

4일 ago | 0

| accepted

Answered

Solve the limit limx→0

Hint: If you are just looking to get an answer, consider looking at the Taylor Series of each individual term and then ask yours...

Solve the limit limx→0

Hint: If you are just looking to get an answer, consider looking at the Taylor Series of each individual term and then ask yours...

4일 ago | 0

Answered

Filling a matrix without for-loops and ifs

Check out the sub2ind( ) function: https://www.mathworks.com/help/matlab/ref/sub2ind.html?searchHighlight=sub2ind&s_tid=doc_src...

Filling a matrix without for-loops and ifs

Check out the sub2ind( ) function: https://www.mathworks.com/help/matlab/ref/sub2ind.html?searchHighlight=sub2ind&s_tid=doc_src...

4일 ago | 0

Answered

Vectorizing evaluation of cell array of functions

Not sure this will be any faster since the loop is just hidden, but you can try this: output = arrayfun(@(x,y)x{1}(y),funcell,i...

Vectorizing evaluation of cell array of functions

Not sure this will be any faster since the loop is just hidden, but you can try this: output = arrayfun(@(x,y)x{1}(y),funcell,i...

4일 ago | 1

Answered

Wondering if you have any merchandise for sale cause I'd love to look like a part of the MATLAB team 😀

How about a MATLAB/Simulink Rubik's Cube? https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=matlab+rubiks&_saca...

Wondering if you have any merchandise for sale cause I'd love to look like a part of the MATLAB team 😀

How about a MATLAB/Simulink Rubik's Cube? https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=matlab+rubiks&_saca...

4일 ago | 0

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 ...

5일 ago | 3

| accepted

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...

5일 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 ...

9일 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...

9일 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...

9일 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.

10일 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...

10일 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...

10일 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}])

13일 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...

13일 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 =...

15일 ago | 0