Answered

Converting output from 'find' into a logical

E.g., x = the result of the find y = false(22879,1); y(x) = true; But it may be better to create y with a direct logical exp...

Converting output from 'find' into a logical

E.g., x = the result of the find y = false(22879,1); y(x) = true; But it may be better to create y with a direct logical exp...

ungefär en månad ago | 0

| accepted

Answered

Remove all infinite values from ydata and then remove those same indices from the xdata so the vectors remain the same length

x = isinf(ydata); ydata(x) = []; xdata(x) = []; Or, if you need to extract the values into new variables, x = ~isinf(ydata);...

Remove all infinite values from ydata and then remove those same indices from the xdata so the vectors remain the same length

x = isinf(ydata); ydata(x) = []; xdata(x) = []; Or, if you need to extract the values into new variables, x = ~isinf(ydata);...

ungefär en månad ago | 0

Answered

Different results by changing the order of operations

You haven't broken up the calculations properly. I.e., you are comparing different calculations. Your code is essentially: ...

Different results by changing the order of operations

You haven't broken up the calculations properly. I.e., you are comparing different calculations. Your code is essentially: ...

ungefär en månad ago | 1

| accepted

Answered

Grabbing sections of a matrix by using two doubles as the index

E.g., result = arrayfun(@(x1,x2)data(x1:x2),find(indStart),find(indEnd),'uni',false); This assumes of course that the indStart...

Grabbing sections of a matrix by using two doubles as the index

E.g., result = arrayfun(@(x1,x2)data(x1:x2),find(indStart),find(indEnd),'uni',false); This assumes of course that the indStart...

ungefär 2 månader ago | 1

| accepted

Answered

1-2-1 or X-Y-X rotation matrix not supported

According to the doc here: https://www.mathworks.com/help/aerotbx/ug/angle2quat.html?s_tid=doc_ta The angle2quat supports the ...

1-2-1 or X-Y-X rotation matrix not supported

According to the doc here: https://www.mathworks.com/help/aerotbx/ug/angle2quat.html?s_tid=doc_ta The angle2quat supports the ...

ungefär 2 månader ago | 1

| accepted

Answered

Plotting a System of Two Second-Order Differential Equations

You've got a 4th order system, so your initial state must contain four elements including the x1' and x2', not two. E.g., [t, ...

Plotting a System of Two Second-Order Differential Equations

You've got a 4th order system, so your initial state must contain four elements including the x1' and x2', not two. E.g., [t, ...

2 månader ago | 0

| accepted

Answered

hex2num can't recover value from the hex by num2hex

Try typecast(uint32(hex2dec('be361af6')),'single')

hex2num can't recover value from the hex by num2hex

Try typecast(uint32(hex2dec('be361af6')),'single')

2 månader ago | 1

Answered

Comparing any of the matrix input

Hints: What does this result give you: classes == x Then look at this: doc any

Comparing any of the matrix input

Hints: What does this result give you: classes == x Then look at this: doc any

2 månader ago | 0

Answered

()-indexing must appear last in an index expression.

You've got closing and opening parentheses next to each other: ...)(... MATLAB thinks you are trying to use the second part as...

()-indexing must appear last in an index expression.

You've got closing and opening parentheses next to each other: ...)(... MATLAB thinks you are trying to use the second part as...

2 månader ago | 0

Answered

Rotation order of quatrotate

I suppose this drawn out explanation is long overdue in this forum, so forgive me for being verbose, but a lot of posters have h...

Rotation order of quatrotate

I suppose this drawn out explanation is long overdue in this forum, so forgive me for being verbose, but a lot of posters have h...

2 månader ago | 0

Answered

Single precision matrix multiplication

To illustrate what Matt is saying, a simple timing test: >> format longg >> S = round(10000*single(rand(5000)+rand(5000)*1i));...

Single precision matrix multiplication

To illustrate what Matt is saying, a simple timing test: >> format longg >> S = round(10000*single(rand(5000)+rand(5000)*1i));...

2 månader ago | 2

Answered

Using MEX file with the main program of Fortran code

You would need to turn the PROGRAM line into a MEXFUNCTION line and add some code for getting the MATLAB variable data to/from t...

Using MEX file with the main program of Fortran code

You would need to turn the PROGRAM line into a MEXFUNCTION line and add some code for getting the MATLAB variable data to/from t...

2 månader ago | 0

Answered

An explicit Runge Kutta of Fourteen Order code

4th Order RK is here: https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

An explicit Runge Kutta of Fourteen Order code

4th Order RK is here: https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

2 månader ago | 0

| accepted

Answered

Why does mxSetDoubles crash this MEX file?

This line is crashing your code: mxSetDoubles(plhs[0],a); You can't re-use data pointers this way. You have essentially share...

Why does mxSetDoubles crash this MEX file?

This line is crashing your code: mxSetDoubles(plhs[0],a); You can't re-use data pointers this way. You have essentially share...

2 månader ago | 0

Answered

Highest power of 2 that divides n.

In addition to David's comments, you need to do all of the calculations symbolically, so all of these should be sym: 2, i, r.

Highest power of 2 that divides n.

In addition to David's comments, you need to do all of the calculations symbolically, so all of these should be sym: 2, i, r.

2 månader ago | 0

| accepted

Answered

Can someone help me convert C++ to Matlab

The += and *= operators behave as follows: total_salary += daily_salary; becomes total_salary = total_salary + daily_salary; ...

Can someone help me convert C++ to Matlab

The += and *= operators behave as follows: total_salary += daily_salary; becomes total_salary = total_salary + daily_salary; ...

3 månader ago | 0

Answered

Operands to the || and && operators must be convertible to logical scalar values

Did you mean this for u = 1:height<=u for v = 1:width<=v to be this for u = 1:height for v = 1:width

Operands to the || and && operators must be convertible to logical scalar values

Did you mean this for u = 1:height<=u for v = 1:width<=v to be this for u = 1:height for v = 1:width

3 månader ago | 0

| accepted

Answered

find max of vector

Two things. FIrst, you need to initialize pos = 1 before the loop starts. And second, you need to modify your if-test to do tw...

find max of vector

Two things. FIrst, you need to initialize pos = 1 before the loop starts. And second, you need to modify your if-test to do tw...

3 månader ago | 0

Answered

How to define an axis based on multiple quaternions?

Assume you have the following: q1 = quaternion from ECI to BODY at time1 (i.e., BODY1 frame) q2 = quaternion from ECI to BODY ...

How to define an axis based on multiple quaternions?

Assume you have the following: q1 = quaternion from ECI to BODY at time1 (i.e., BODY1 frame) q2 = quaternion from ECI to BODY ...

3 månader ago | 0

| accepted

Answered

Repeat elements of a vector as matrixes in a multidimensional array.

Another way: m = size of 1st dimension n = size of 2nd dimension v = your row vector result = reshape(repmat(v,m*n,1),m,n,[]...

Repeat elements of a vector as matrixes in a multidimensional array.

Another way: m = size of 1st dimension n = size of 2nd dimension v = your row vector result = reshape(repmat(v,m*n,1),m,n,[]...

3 månader ago | 1

Answered

Sorting numbers in an array without sort function

Simply set your "finished" flag depending on whether a swap was done or not. E.g., while true finished = 1; for i=1:s...

Sorting numbers in an array without sort function

Simply set your "finished" flag depending on whether a swap was done or not. E.g., while true finished = 1; for i=1:s...

3 månader ago | 0

| accepted

Answered

Need help finding intercept in a polynomial function

Why can't you just find the real roots of f(x)-600? What am I missing here?

Need help finding intercept in a polynomial function

Why can't you just find the real roots of f(x)-600? What am I missing here?

3 månader ago | 0

| accepted

Answered

Picking a random row of a matrix

k = randi(size(Y,1)); % the random row index Y(k,:) is the random row

Picking a random row of a matrix

k = randi(size(Y,1)); % the random row index Y(k,:) is the random row

3 månader ago | 0

| accepted

Answered

Replacing all elements in a row with zeros, if atleast one of the elements in the row is greater than 1

Another method if you want the replacement in-place: A(any(A>1,2),:) = 0;

Replacing all elements in a row with zeros, if atleast one of the elements in the row is greater than 1

Another method if you want the replacement in-place: A(any(A>1,2),:) = 0;

3 månader ago | 0

| accepted

Answered

Large, unused cell aray in memory still slows down calculation significantly

Can you clarify if the above code is included in your timings? For all we know, you are simply showing that creating 44100 sepa...

Large, unused cell aray in memory still slows down calculation significantly

Can you clarify if the above code is included in your timings? For all we know, you are simply showing that creating 44100 sepa...

3 månader ago | 0

Answered

ActiveX: how to pass a string array to cst in matlab？

Couple of things you might also try sWidth={'0.5';'1.1';'2.2';'3.3'}; or sWidth={'0.5';'1.1';'2.2';'3.3'}; sWidth = cellfun(...

ActiveX: how to pass a string array to cst in matlab？

Couple of things you might also try sWidth={'0.5';'1.1';'2.2';'3.3'}; or sWidth={'0.5';'1.1';'2.2';'3.3'}; sWidth = cellfun(...

3 månader ago | 0

Answered

I am having a lot of trouble with the built in mode function

You have inadvertently created a variable called "mode" that is shadowing the MATLAB mode( ) function. Track down where that is ...

I am having a lot of trouble with the built in mode function

You have inadvertently created a variable called "mode" that is shadowing the MATLAB mode( ) function. Track down where that is ...

3 månader ago | 0

| accepted

Answered

Debugging matrix dimensions error

How to debug: Type the following at the MATLAB prompt: dbstop if error Then run your code. When the error occurs, the code wi...

Debugging matrix dimensions error

How to debug: Type the following at the MATLAB prompt: dbstop if error Then run your code. When the error occurs, the code wi...

3 månader ago | 0

Answered

Table of Matlab release features

Note that a similar list of version specific mex related features (mxArray changes, API functions, etc.) can be found here in th...

Table of Matlab release features

Note that a similar list of version specific mex related features (mxArray changes, API functions, etc.) can be found here in th...

3 månader ago | 3

Answered

Adding a row to an unknown matrix - the row consists of the mean value of the columns of the unknown matrix.

Hints: doc mean The last row of the matrix A is A(end,:). Then ask yourself: What would be the indexing of one row beyond "en...

Adding a row to an unknown matrix - the row consists of the mean value of the columns of the unknown matrix.

Hints: doc mean The last row of the matrix A is A(end,:). Then ask yourself: What would be the indexing of one row beyond "en...

3 månader ago | 0

| accepted