Community Profile

photo

James Tursa


Last seen: Today
3,608 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.

Contact

James Tursa's Badges

  • Revival Level 3
  • Master
  • Personal Best Downloads Level 3
  • First Review
  • 5-Star Galaxy Level 5
  • First Submission
  • 36 Month Streak
  • Thankful Level 2
  • Knowledgeable Level 4
  • First Answer
  • Solver

View details...

Contributions in
View by

Answered
Why does defining a system of ODEs a different, but similar way yield very different solutions?
Do you simply need to apply that factor in the 6th spot? (kred(t)*CNiIIIH - kox(t)*CNiIIH - k2*CNiIIH*CH)*(96485.33289/1e9);

18 hours ago | 0

Answered
atan2(0,0) is not undefined (NaN)
This is a documented convention. https://ch.mathworks.com/help/matlab/ref/atan2.html

3 days ago | 0

Answered
How to use not equal in for loop
You could use a while loop. E.g., t = 0; while( t ~= 1 ) % code % at some point, either set t=1 or break out of loop...

4 days ago | 0

Answered
Given that A is a sparse matrix, norm(A(i,:)) takes a very long time. Why and can one do better ?
Will you eventually need all of the rows? E.g., do this once at the beginning outside the loop n = sqrt(sum(A.^2,2)) And then...

5 days ago | 0

Answered
8bit binary sub string to unsigned integer in matlab
doc bin2dec

6 days ago | 0

Answered
Indexing in fields of a struct
Loops are what is needed here, but you can hide the loops behind function calls if you want. E.g., k = 3; % the number you are...

7 days ago | 0

| accepted

Answered
Using FP16 data in MATLAB
If you have R2018b or later, you can fread as uint16 and then typecast into half type. E.g., % Generate some sample data >> d...

7 days ago | 0

| accepted

Answered
I'm new to matlab and am trying to sort an array in ascending order without using the sort command. How would I rectify this?
This is a "bubble sort" and you have two problems. First, as mentioned by Walter, is your indexing max value is one too big. Y...

8 days ago | 1

Answered
Preallocating a sparse matrix, then entering values column by column takes too much time. Is there a more efficient way ?
The problem is that every time you change the elements of Q, even if it is only one element change, MATLAB generally has to copy...

10 days ago | 0

Answered
How to optimize matrix multiplication speed?
This looks like a covariance matrix update to me. The matrix multiplies are already done by highly optimized multi-threaded com...

11 days ago | 0

Answered
How to limit calculation precision?
You can get about that precision (a little less) by using the half data type: https://www.mathworks.com/help/fixedpoint/ref/hal...

14 days ago | 1

Answered
FOR LOOP NOT WORKING
Index your answers. E.g., if EXANGLES(i) < 90 EVANGLE1(i) = EVSUB1-FT126; elseif EXANGLES(i) == 90 ...

15 days ago | 0

Answered
Numerical Solution of the System of four Coupled Nonlinear ODEs by Runge-Kutta Fourth Order Method
I will point out some problems, and then suggest a much easier way to do this. Start with your first couple of lines in the loo...

15 days ago | 0

Answered
can i get mex files in matlab format?
Mex files are compiled (i.e., machine language) DLL files. You cannot view them in MATLAB m-file format. If you have the C/C++...

15 days ago | 0

| accepted

Answered
I need help obtaining the values c1,c2.c3 from a least squares fit of the data.
It appears to me that your equation is linear in c1, c2, c3. Just make a matrix equation out of this and then apply your least ...

16 days ago | 0

Answered
How to add an NxN matrix with K pages ?
You are correct, sum(A,3) is the correct syntax to use. This sums across the 3rd dimension.

21 days ago | 0

Answered
How do I vectorize matrices of specific modes of a tensor?
Is this what you want? x = your 250 x 250 x 183 array result = reshape(x,250*250,183);

22 days ago | 0

Answered
Why the memory Limitation to a data structure in cpp: size of "XXX::C_SubNetwork::S_ListBuffer [3]" >= 256 Mb and can I raise the limit higher?
This looks like you are declaring this variable as a local variable, in which case the memory for it will come off of the stack....

24 days ago | 0

Answered
mxCreateNumericMatrix and sparse matrix in C/Matlab hybrid programming
Convert the index arrays to double either inside the C code or on the Engine side. E.g., engEvalString(ep, "MS=sparse(double(MI...

27 days ago | 0

Answered
Converting double values file to 2 byte per sample.
If you want a two byte floating point representation you can use half precision. E.g., https://www.mathworks.com/matlabcentral/...

29 days ago | 0

Answered
How can I multiply N dimensional matrices
Other options from the FEX: https://www.mathworks.com/matlabcentral/fileexchange/8773-multiple-matrix-multiplications-with-arra...

29 days ago | 1

Answered
whats difference beetween angvel and rotvec?
I don't have a version of MATLAB installed that has the angvel( ) and rotvec( ) functions, so I can only make an educated guess....

30 days ago | 0

Answered
Strncpy/Strncpy_s is supported by Matlab
Your code has bugs. That is why it is crashing. The bugs are caused by these lines: main(); // You call main without any ...

30 days ago | 0

Answered
Fast conversion of 2 matrices to 1 complex matrix
See this FEX submission for reading and writing interleaved complex data in R2018a or later without extra data copies: https://...

1 month ago | 0

Answered
How to replace leading zeroes by spaces with regexprep
One way: fun = @(x)sprintf(['%' num2str(numel(x)) 'd'],str2double(x)); d = cellfun(fun,a,'uni',false); e = cellfun(fun,b,'uni...

1 month ago | 0

Answered
trimming matrix arrays arranged within cell arrays
It is not clear whether you want the rows or columns trimmed. Maybe one of these is what you want? TrimmedArray = cellfun(@(x) ...

1 month ago | 0

Answered
Runge-Kutta 4th order function error (Matrix dimensions must agree)
Your RK_4 function is not set up to handle vector equations ... it is only set up to handle scalar equations. Also you are not ...

1 month ago | 0

Answered
How to pass arguments by reference from Matlab?
doc loadlibrary Create a C header file that gives prototypes for the Fortran subroutines and treat the Fortran arguments as poi...

1 month ago | 0

Answered
how to create an array of all permutations
If you want all of them in an array (which might be too large if the number of digits is too large), you can use n = number of ...

1 month ago | 0

| accepted

Answered
Trying to do calculations for density
Why do you have these lines in your function: P_t=4; P_s=3; H=25; Aren't these variable supposed to be input arguments? See...

1 month ago | 0

| accepted

Load more