# James Tursa

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

**Statistics**

RANK**16**

of 239.103

REPUTATION**12.323**

CONTRIBUTIONS

**17** Questions

**3.959** Answers

ANSWER ACCEPTANCE **
35.29%
**

VOTES RECEIVED**2.199**

RANK**165** of 16.798

REPUTATION**7.143**

AVERAGE RATING**4.60**

CONTRIBUTIONS**32** Files

DOWNLOADS **156**

ALL TIME DOWNLOADS**66855**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

Mean computaion in matlab

You can specify the dimension to use with the mean( ) function. E.g., maybe this is the computation you want: data = your 3D m...

1 giorno ago | 0

What is the mean?

B' is the complex conjugate transpose of B. If B is real, then it is equivalent to just the tranpose and the assignment simply ...

3 giorni ago | 0

| accepted

How can I model equation of motion (2nd order ODE) when system matrices are in terms of state variables?

Yes you can have derivative functions that depend on state variables. This is quite common. E.g., define a 4x1 state vector y th...

4 giorni ago | 0

empty double matrix in case of nul value

Do you mean you want to do something like this: if( isempty(malicious) ) malicious = 0; end

14 giorni ago | 0

To allocate character array='2a'

'2a' is a two element character string. You can't assign two elements to a single element. I.e., you can't assign a 1x2 vector...

17 giorni ago | 0

How to get the desired quaternion representation from a rotation matrix?

As you already know, both q and -q represent the same rotation. Which sign to pick is entirely up to the underlying algorithm. ...

25 giorni ago | 0

| accepted

Implementation of Runge Kutta Numerical Solution for system of ODE's

The main technical problem (other than your syntax not being MATLAB) is that you are trying to solve your four 1st order equatio...

circa un mese ago | 0

| accepted

How to convert complex float to complex integer in MEX gateway function?

I would guess you can just use the appropriate data types. E.g., mxComplexInt32* Data1 = mxGetComplexInt32s(prhs[0]); mxComp...

circa un mese ago | 0

| accepted

Can you help me with this loop?

Can you use num2str? Message = [num2str(TotalMinutes) ' minutes are equal to ' num2str(Hours) ' hours and ' num2str(Minutes) ' ...

circa un mese ago | 0

How to separate a string(1x1 cell) into a 1x4 cell

If the hex codes are always 8 characters, why can't you just pick off the characters you want? E.g., {result(1:8),result(10:17...

circa un mese ago | 1

how to generate a code for solving 2st order differential equations using improved runge kutta 4th order method

The posted code actually has a bug. Also it is almost set up properly for vector solutions, but not quite. Make these changes:...

circa un mese ago | 0

Computer crashed when calculating matrix (mixed with sparse and full) multiplication and summation

Remember that each element of the B*C result is simply the dot product of a row of B with a column of C. If that column of C ha...

circa un mese ago | 0

| accepted

Fast vector reshaping/permutation

Don't do the permute( ) operation. Just use pagemtimes( ) downstream in your code with the appropriate 'transpose' option. Thi...

circa un mese ago | 1

Can someone explain this Loop?

Of the numbers 1 ... 10 that get produced by the randperm( ) call, only three of them are less than 4: 1, 2, 3. 1 will cause n...

circa un mese ago | 0

| accepted

How to generate unique random integers between 1 to n (with no possibility of Sequence)

If 1:n is the only sequence you don't want, just use randperm(n) and reject the one case you don't want. I.e., if you get it the...

circa un mese ago | 0

How do solve four variables with one equation using Runge-kutta?

You have three state variables, namely v, lc, and z. But you only have code for updating v. You need code for updating lc and ...

circa un mese ago | 1

| accepted

A code and plot a graph for a projectile motion of a ball

Your main problem is that you don't have enough state variables. You have these two equations: x'' = 0 y'' = -g That's two 2...

circa un mese ago | 0

Converting Struct field to array

Does this do what you want? MyMatrix = vertcat(MyStruct.Field);

circa un mese ago | 0

| accepted

Trying to build a new nx4 array from an existing nx4 array using logical values

Assuming quatAB is a standard numeric matrix, use your logical variable for the first index and colon for the second index: m =...

circa 2 mesi ago | 0

How do I combine a structure array into one structure

F = fieldnames(A); n = numel(F); C = arrayfun(@(i)vertcat(A.(F{i})),1:n,'uni',false); FC = [F';C]; B = struct(FC{:});

circa 2 mesi ago | 0

Finding optimal value for x

You could try this function to get numeric values for local minimums: https://www.mathworks.com/help/matlab/ref/fminsearch.html...

circa 2 mesi ago | 0

Using fprintf to save a matrix changes the order of my matrix

MATLAB stores 2D matrices in column order. That is, the numbers in your matrix are stored in memory in this order: 0, 1, 2, 3,...

circa 2 mesi ago | 0

please help me to convert c code into matlab code for partial shading of solar panel using equilibration algorithm

In addition to what @Image Analyst has written, I would advise turning this into a function with p1, p2, p3 as input arguments a...

circa 2 mesi ago | 0

Difference between using single quotes ('xyz') and double quotes ("xyz") in formatspec

In MATLAB, single quotes ' ' are used to create char type variables, and double quotes " " are used to create string type variab...

circa 2 mesi ago | 0

| accepted

Error in ode45 while doing numerical integration

The function handle you pass to ode45( ) needs to have a (t,y) signature. E.g., [t,y] = ode45(@(t,y) myode(t,gt,g), tspan, ic, ...

circa 2 mesi ago | 0

How to multiply higher order matrices?

You may need to permute your arrays first to get your desired 2D slices in the first two dimensions. A = whatever B = whatever...

circa 2 mesi ago | 2

Using matrix to index another matrix?

Does this do what you want: x = sub2ind(size(B),(1:size(A,1))',A(:,1),A(:,2),A(:,3)); Output = B(x);

circa 2 mesi ago | 0

| accepted

Equivalent of c++'s NULL or python' s None in MATLAB

This will probably depend on how these are used downstream in your code and whether you have arrays of them to deal with. If th...

2 mesi ago | 1

X Y Z angles of a D20 (icosahedron) for gravity projection

If you have the 3D normal vectors, then all you need to do is take the dot product between them and the "flat" face normal vecto...

2 mesi ago | 1

| accepted

modify a row of an array within a function

This can sometimes be done inplace depending on how you write the function and how you call the function. One requirement is yo...

2 mesi ago | 0