# 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**17**

of 262 893

REPUTATION**12 892**

CONTRIBUTIONS

**17** Questions

**4 103** Answers

ANSWER ACCEPTANCE **
41.18%
**

VOTES RECEIVED**2 362**

RANK**164** of 17 994

REPUTATION**7 299**

AVERAGE RATING**4.60**

CONTRIBUTIONS**32** Files

DOWNLOADS **152**

ALL TIME DOWNLOADS**68419**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

How to get two 16-bit numbers from a 32bit number

E.g., to split a uint32 into two uint16 you can use typecast( ): result = typecast(your_variable,'uint16') This result will co...

ungefär 7 timmar ago | 0

pass a vector from matlab to a c++ program

This really depends on what your C++ program does, but the simplest approach is to use a mex routine. You will need a supported ...

3 dagar ago | 0

Write multiple variables from a function

Maybe something like this does what you want, with each qq1 and qq2 2D page results in the first two dimensions. [m n] = size(s...

11 dagar ago | 0

In an assignment A(I) = B, the number of elements in B and I must be the same.

" And in the work space y2 is 3x1 and d is 1x1 " Then d - y2 will be 3x1. You can't assign a 3-element vector to a 1x1 scalar w...

12 dagar ago | 0

After the if statement is ran why is the answer 10?

A=1; : if A<0 A is not negative, so the body of the if-test never runs.

17 dagar ago | 0

Solve nonlinear 2nd order ODE numerically

You can look at the examples for ode45( ) here: https://www.mathworks.com/help/matlab/ref/ode45.html?searchHighlight=ode45&s_ti...

19 dagar ago | 1

The input function does not work well

Pass in a vector using the square brackets. E.g., binary_to_decimal([1 0 0 1 1 0])

20 dagar ago | 0

| accepted

Concatenate logical/numerical arrays element wise

Here is one way: % Generate sample data H{1} = rand(2,3)<0.5; H{2} = rand(2,3)<0.5; H{3} = rand(2,3)<0.5; Hc = cat(3,H{:}) ...

20 dagar ago | 2

| accepted

What is the difference between " while 1" and "while true", Should I use one over the other?

1 is a double class scalar and true is a logical class scalar, so the check for "non-zero" is slightly different for each even t...

22 dagar ago | 0

| accepted

I have a 4 Dimensional Matrix and i want to get its transpose

Maybe this does what you want, which is transpose the first two dimensions: permute(val,[2 1 3 4]) Or you could use this funct...

27 dagar ago | 0

How to multiply a 3d array with a 2d matrix?

It would be best if your 2D pages were the first two dimensions. That way the 2D pages are contiguous in memory and you can use ...

ungefär en månad ago | 1

Error in concatination in binary values

c1=[8 14 10 9 6 3 2 7 6 11 6 3 13 15 6 0]; NewR = c1(1:2:end)*16 + c1(2:2:end)

ungefär en månad ago | 0

Increased time for setting elements in sparse matrix

Every time you change the elements of a sparse matrix, MATLAB has to deep copy all the existing elements to a newly allocated ch...

ungefär en månad ago | 1

How to run a Matlab file which uses functions from .c and .dll files?

It appears that this may be an older mex routine? Is there a "mexFunction" in the c file? If so, maybe you can just recompile it...

ungefär 2 månader ago | 1

| accepted

Unable to perform assignment because the left and right sides have a different number of elements.

Why are you replacing the sin(y-c) term with approximations? Why haven't you just programmed it as is? It appears you have done ...

ungefär 2 månader ago | 0

Applying runge kutta for coupled equations

What are and ? Why don't they have differential equations associated with them? Can you give more details about this? Also, it...

ungefär 2 månader ago | 0

| accepted

How to create a loop on function handle

Isn't this just a standard matrix*vector multiply? E.g., XI = @(xi) xi - (y(i,:) + A*((t(i)+c*dt).*xi)*dt); Note that this fun...

ungefär 2 månader ago | 1

| accepted

Index Matrix A and Matrix B Problems

You can use logical indexing: B(A==1) = 0; You can use a loop for this also, but you would have to show us the code you used b...

ungefär 2 månader ago | 1

Whole derivation of two variable differential function

Please show the code you are using. y' means derivative of y with respect to x, not derivative of y with respect to y. You sho...

ungefär 2 månader ago | 0

How do i compile multiple fortran code from matlab command

To pass variables from MATLAB to your Fortran code you would typically do the following: Write a single gateway routine in a se...

2 månader ago | 0

Updating Sparse Matrices every Time-Step Efficiently

To specify the sparse matrix size when creating it, use the following syntax: sparse(I,J,K,m,n) where m is the number of rows ...

2 månader ago | 0

How to set specific size of a figure with exportgraphics?

This doesn't answer your question about controlling exported sizes, but you might be interested in the following export_fig FEX ...

2 månader ago | 0

Renaming the variabel while Symbolic to function handle conversion with matlabFunction

You could keep your existing code and create another function handle: funcv = @(A,xdata,ydata)func(A(1),A(2),xdata,ydata)

2 månader ago | 0

Making an Array out of another Array if conditions are met

You don't need a for-loop for this. The best way is to use logical indexing. See this link: https://www.mathworks.com/help/matl...

2 månader ago | 0

| accepted

How to remove February 29th for leap years in a daily time series over 43 years?

To get rid of the leap days, you can use evenly spaced indexing since the number of days between leap days is constant for your ...

3 månader ago | 0

I would like to write a for loop to store all values of y when A=1,2,3,4,5. into a variable y1,y2,y3,y4,y5 respectively. Any help will be greatly appreciated. Thanks

No loop needed, and no need to create multiple variables to hold results. Just use implicit array expansion and hold results in ...

3 månader ago | 0

| accepted

Index in position 1 is invalid. Array indices must be positive integers or logical values.

Looks like you changed the definition of what f_m is in your code. In these lines f_m appears to be an array intended to hold va...

3 månader ago | 1

What does A(2:4) = [ ] do if A is a 3x3 matrix?

This is linear indexing. Even though the variable is a 2D matrix, MATLAB allows you to index into it using only one index. The l...

3 månader ago | 1

error using function code

Create a file called lettergrade.m somewhere on the MATLAB path (e.g., in your working directory) edit lettergrade.m Copy all ...

3 månader ago | 0