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

Answered

Function takes as input two nonempty matrices A and B and returns the product AB

This is a matrix multiply, so you need to keep the rows and columns of the inputs separately. E.g., [NRowsA,NColsA] = size(A);...

Function takes as input two nonempty matrices A and B and returns the product AB

This is a matrix multiply, so you need to keep the rows and columns of the inputs separately. E.g., [NRowsA,NColsA] = size(A);...

9 days ago | 0

Answered

Roll a die until n consecutive rolls have the same value

You made a good start, but it might help to change your inner while loop exit condition to be exactly what you are looking for ....

Roll a die until n consecutive rolls have the same value

You made a good start, but it might help to change your inner while loop exit condition to be exactly what you are looking for ....

9 days ago | 0

| accepted

Answered

Solve function give 2 answers when there should be 1.

For a generic orbit problem, i.e. an ellipse, there are always going to be two places on the orbit path with the same r value (e...

Solve function give 2 answers when there should be 1.

For a generic orbit problem, i.e. an ellipse, there are always going to be two places on the orbit path with the same r value (e...

14 days ago | 0

| accepted

Answered

MatLab While loop indexing?

Add a counter to your loop. Initialize the counter to 0 and add 1 to it within the loop. E.g., counter = 0; % other stuff w...

MatLab While loop indexing?

Add a counter to your loop. Initialize the counter to 0 and add 1 to it within the loop. E.g., counter = 0; % other stuff w...

14 days ago | 0

| accepted

Answered

Extracting a submatrix based on conditions on first columns of a big matrix

BigMatrix = your big matrix BigMatrix1 = BigMatrix(:,1); % 1st column x = BigMatrix1 > 527 & BigMatrix1 < 580; % logical index...

Extracting a submatrix based on conditions on first columns of a big matrix

BigMatrix = your big matrix BigMatrix1 = BigMatrix(:,1); % 1st column x = BigMatrix1 > 527 & BigMatrix1 < 580; % logical index...

14 days ago | 0

| accepted

Answered

Can someone help me figure out what is wrong with my function c1 = ult_trid(m,b) ??

d is a 4x1 vector and you are trying to access the d(4,4) element, hence the error.

Can someone help me figure out what is wrong with my function c1 = ult_trid(m,b) ??

d is a 4x1 vector and you are trying to access the d(4,4) element, hence the error.

20 days ago | 0

Answered

Question about numerical integration for cos vs cosd

By hand: int cosd(theta) = int cos(theta*pi/180) = sin(theta*pi/180)*180/pi Integrated from 0 to 15 degrees: sin(15*pi/180)...

Question about numerical integration for cos vs cosd

By hand: int cosd(theta) = int cos(theta*pi/180) = sin(theta*pi/180)*180/pi Integrated from 0 to 15 degrees: sin(15*pi/180)...

20 days ago | 2

| accepted

Answered

Error: File: d3.m Line: 7 Column: 10 Invalid use of operator.

Looks like you are missing some variable names and some matching parentheses in this line: scatter((:,1)),(:,2)),'o')

Error: File: d3.m Line: 7 Column: 10 Invalid use of operator.

Looks like you are missing some variable names and some matching parentheses in this line: scatter((:,1)),(:,2)),'o')

21 days ago | 0

Answered

Please help me write the f function in matlab

I would assume from the equation image that the exp( ) stuff maybe should be outside of the sin( ) stuff. E.g., f = 2.*x.*sin(...

Please help me write the f function in matlab

I would assume from the equation image that the exp( ) stuff maybe should be outside of the sin( ) stuff. E.g., f = 2.*x.*sin(...

21 days ago | 0

Answered

How to create multiple matrices with different sizes without a loop?

You will either need to use loops, or hide the loops behind a function call (e.g., arrayfun): result = arrayfun(@(x)randi([0 x]...

How to create multiple matrices with different sizes without a loop?

You will either need to use loops, or hide the loops behind a function call (e.g., arrayfun): result = arrayfun(@(x)randi([0 x]...

22 days ago | 0

| accepted

Answered

Inserting a column in a matrix before adding it to another matrix in a loop

C = [A,[B1;B2;B3]];

Inserting a column in a matrix before adding it to another matrix in a loop

C = [A,[B1;B2;B3]];

22 days ago | 0

Answered

I need help solving a equation with the Runge-Kutta-Fehlberg adaptive step size method using ode45.

For Problem 2 and Problem 3, you should not be looping over any variables. You simply have a derivative function that you pass ...

I need help solving a equation with the Runge-Kutta-Fehlberg adaptive step size method using ode45.

For Problem 2 and Problem 3, you should not be looping over any variables. You simply have a derivative function that you pass ...

22 days ago | 0

Answered

Wrapper to run 32-Bit mex files on 64-Bit MATLAB

32-bit mex files are not standalone code. They interact with 32-bit MATLAB library code which interacts with the 32-bit MATLAB ...

Wrapper to run 32-Bit mex files on 64-Bit MATLAB

32-bit mex files are not standalone code. They interact with 32-bit MATLAB library code which interacts with the 32-bit MATLAB ...

22 days ago | 0

Answered

Taylor series for sin(x) doesn't give the right answer above 34 radians

The larger x is, the more cancellation error you are going to get with the intermediate sums. It would be best to reduce the ra...

Taylor series for sin(x) doesn't give the right answer above 34 radians

The larger x is, the more cancellation error you are going to get with the intermediate sums. It would be best to reduce the ra...

22 days ago | 0

Answered

code for eulers method help

This needs to be outside of and prior to your loop, and r needs a multiply operator: f=@(y)r*(1-(y/L))*y-((p*y^2)/(q+y^2)); Th...

code for eulers method help

This needs to be outside of and prior to your loop, and r needs a multiply operator: f=@(y)r*(1-(y/L))*y-((p*y^2)/(q+y^2)); Th...

23 days ago | 1

Answered

minutes to hour and minutes

Make mins a column vector, or use mins(:) in your function handle.

minutes to hour and minutes

Make mins a column vector, or use mins(:) in your function handle.

23 days ago | 0

Answered

syntax error using complex loops

Did you mean while c <= 19 For loops should be looping over a fixed number of iterations, not a logical condition. While loop...

syntax error using complex loops

Did you mean while c <= 19 For loops should be looping over a fixed number of iterations, not a logical condition. While loop...

24 days ago | 0

Answered

Create Array that reorders given values to have smallest first and largest last while maintaining the rest of the array.

That 2nd loop needs to run in reverse order. You need to bubble that smallest number which might be near the back all the way t...

Create Array that reorders given values to have smallest first and largest last while maintaining the rest of the array.

That 2nd loop needs to run in reverse order. You need to bubble that smallest number which might be near the back all the way t...

24 days ago | 0

Answered

Need helping creating and solving for this equation: f(t)=4- t^2 e^(-3t)

Here is a basic outline to get you started: n = 100; % Number of elements t = zeros( you fill this in ); % create an t vector ...

Need helping creating and solving for this equation: f(t)=4- t^2 e^(-3t)

Here is a basic outline to get you started: n = 100; % Number of elements t = zeros( you fill this in ); % create an t vector ...

26 days ago | 0

Answered

How can I use a for loop to create new variables?

You might consider automatic array expansion. E.g., look at this result: t = 0:0.01:10; % row a = [0.1 1 3]'; % column y = e...

How can I use a for loop to create new variables?

You might consider automatic array expansion. E.g., look at this result: t = 0:0.01:10; % row a = [0.1 1 3]'; % column y = e...

29 days ago | 1

Answered

Can someone convert this to matlab code?

So, you don't need any loops for this. Just use the automatic array expansion feature. E.g., take a look at what happens with ...

Can someone convert this to matlab code?

So, you don't need any loops for this. Just use the automatic array expansion feature. E.g., take a look at what happens with ...

29 days ago | 0

Answered

Two variables need to be connected to one struct variable.

What about something like this: Results.First_Name = first_name{target}; Results.Last_Name = last_name{target}:

Two variables need to be connected to one struct variable.

What about something like this: Results.First_Name = first_name{target}; Results.Last_Name = last_name{target}:

29 days ago | 0

| accepted

Answered

How would I write the function of f(x)=sin(x)*exp(-x/10)

The multiply. E.g., f = @(x) sin(x) .* exp(-x/10); You don't need it on the divide because you are dividing by a scalar.

How would I write the function of f(x)=sin(x)*exp(-x/10)

The multiply. E.g., f = @(x) sin(x) .* exp(-x/10); You don't need it on the divide because you are dividing by a scalar.

29 days ago | 1

Answered

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'.

This is often caused by using a matrix or vector in an equation when you thought you were using a scalar. E.g., take these lines...

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'.

This is often caused by using a matrix or vector in an equation when you thought you were using a scalar. E.g., take these lines...

29 days ago | 0

| accepted

Answered

Reading 64 bit words

Try reading and keeping the type as uint64 (using the *) instead of converting to double: word = fread(fid,1,'*uint64');

Reading 64 bit words

Try reading and keeping the type as uint64 (using the *) instead of converting to double: word = fread(fid,1,'*uint64');

29 days ago | 0

| accepted

Answered

mex, error C3861: "mxGetDoubles": Cannot find the identifier, "mxGetUint8s": Cannot find the identifier ？

Those functions are for the R2018a memory model API. For that, you need to add the -R2018a option flag: mex myfile.cpp -R2018a...

mex, error C3861: "mxGetDoubles": Cannot find the identifier, "mxGetUint8s": Cannot find the identifier ？

Those functions are for the R2018a memory model API. For that, you need to add the -R2018a option flag: mex myfile.cpp -R2018a...

30 days ago | 0

| accepted

Answered

Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

You are missing an ending parenthesis, and also you probably need to use element-wise multiply: u3 = exp(-0.89*t) .* (1.75*cos(...

Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

You are missing an ending parenthesis, and also you probably need to use element-wise multiply: u3 = exp(-0.89*t) .* (1.75*cos(...

30 days ago | 0

| accepted

Answered

Solving a nonlinear ODE

Step 1: Solve your ODE for the highest order derivative, in this case Rdoubledot (on paper) Rdoubledot = stuff (you figure thi...

Solving a nonlinear ODE

Step 1: Solve your ODE for the highest order derivative, in this case Rdoubledot (on paper) Rdoubledot = stuff (you figure thi...

1 month ago | 0

Answered

Computational Complexity of matrix multiplication

This question is perhaps more involved than it looks on the surface, because by default MATLAB doesn't store the imaginary part ...

Computational Complexity of matrix multiplication

This question is perhaps more involved than it looks on the surface, because by default MATLAB doesn't store the imaginary part ...

1 month ago | 0

| accepted

Answered

error:All functions in a script must be closed with an 'end'.( kindly see the code and help me to remove the error)

Looks like maybe this for iy = 1:H end for ix = 1:W should be just this for iy = 1:H for ix = 1:W Side Note: This would b...

error:All functions in a script must be closed with an 'end'.( kindly see the code and help me to remove the error)

Looks like maybe this for iy = 1:H end for ix = 1:W should be just this for iy = 1:H for ix = 1:W Side Note: This would b...

1 month ago | 0