Community Profile

photo

James Tursa


5134 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

Contributions in
View by

Answered
mxCreateStructArray and mxCreateStructMatrix field name memory management
_"Are the field name character arrays copied before being stored internally?"_ Yes. Internally in the mxArray, the field name...

1 day ago | 1

| accepted

Answered
I am trying to sort three numbers without using inbuilt functions.What is wrong with the function?
Two of your branches do not set all three output variables. E.g., if p(1)<=p(2) if p(1)<=p(3) small...

1 day ago | 0

Answered
Definite Integrals With Answer
For Part A, the instructor may want the answer in terms of x, not t. E.g. syms x disp(int(40-2*t,0,x)) % <-- Or disp(s...

4 days ago | 0

| accepted

Answered
mexPrintf to standard error
Brute force? I can't think of another way to get at the MATLAB standard error printing. E.g., /* Includes ---------------...

4 days ago | 0

| accepted

Answered
Making a matrix using colons or linspace working improperly within code
I suspect this is being caused by floating point round off error in the various calculations. Maybe just use a round in your lin...

4 days ago | 0

| accepted

Answered
find closest pairs in two datetime arrays with unequal length
Are the arrays sorted? Using sorted arrays, one could come up with a stepping algorithm. E.g., if you know that t2(k) < t1(i) ...

7 days ago | 0

Answered
Taylor and Euler Method for ODE
MATLAB is a 0-based indexing language. So you can't have y(0) in your code. It will need to start at y(1). y(1)= -0.25; ...

7 days ago | 0

| accepted

Posted


reading and writing matrices from c++
snip) (snip) Actually, what I meant was how are you doing the compile itself? From within MATLAB or from within Visual Studi...

7 days ago | 215 views

Answered
Coversion of visual c to matlab line
Rather than converting the code, you might consider a mex solution: https://www.mathworks.com/help/matlab/programming-interfa...

7 days ago | 0

Answered
How to pass parameters?
Not sure if this is what you want, but just pass them in: dX = -13.925*A*B*C*x + f(t,A,B,C); : function fval =...

7 days ago | 1

| accepted

Posted


reading and writing messages from c++
Please tell us the MATLAB version you are using and the operating system. Also post the exact code you are using to do the comp...

7 days ago | 215 views

Answered
Trying to graph each iteration of the for loop
You are plotting p(1,:) in the loop, but this never changes in the loop. Did you mean to plot pdot instead? E.g., plot(t,pd...

8 days ago | 0

Answered
4-D array to 3-D array
E.g., x = your 304 * 448 * 37 * 12 array y = reshape(x,304,448,37*12); Another possibility if you want those last two...

8 days ago | 0

| accepted

Answered
Error with matrix dimensions depending on which version of matlab i use.
Guessing that your friends are running R2016b and you are running an earlier version. In R2016b dimension mismatches such as thi...

8 days ago | 2

| accepted

Answered
Problem converting cell to string
If the individual cells can have more than two elements, e.g., U={[1,4],[1,5],[1,6],[2,4],[2,5],[2,6],[3,4,5],[3,5],[3,6,9]...

8 days ago | 0

Answered
Create a new field in a structure
Not sure if this is what you are really asking: mystruct.field1 = rand(1,3); % <-- Create a structure with field named fie...

8 days ago | 0

Answered
Weird!!!! Extremely simple question!! Can't assign values to first row of a sparse matrix, please help.
Typo. You used a small case 's' in that first row assignment. Change that to an upper case 'S' and everything will be as expecte...

9 days ago | 1

| accepted

Answered
A Few Key Concepts to Take From One Complete Program and Apply to Another Very Similar Second Computer Program from an Exponential Distribution with Lambda Function Applied..
I _*think*_ your question is how to generate exponential(lambda) random numbers. If so, you can get them from uniform(0,1) numbe...

9 days ago | 0

| accepted

Answered
How do I isolate a letter in some equation?
symvar is probably what you are looking for. E.g., >> eqn = '2=2*log(x).^2'; >> symvar(eqn) ans = 'x' EDIT...

9 days ago | 1

| accepted

Answered
How to limit user input to only one character?
Maybe this FEX submission by Jos is close to what you want: http://www.mathworks.com/matlabcentral/fileexchange/7465-getkey ...

9 days ago | 0

Answered
Matrix indexing multiple rows
x = your matrix result = x([2:4,5:8],:); % <-- pick off rows 2-4 and 5-8 Of course, the 2:4 and 5:8 could have been com...

9 days ago | 0

Answered
I need to compare two large arrays of data. Running is too slow, it takes 5 days to run the script below. Is it possible to run the script in less time? As?
Not a complete solution, but for starters I would suggest the following: Pull all of the data copying you do that does not de...

9 days ago | 0

Answered
How to repeat a for loop n times
Is this all you are trying to do? n = number of times to repeat the loop States = zeros(size(N,1)); for k=1:n ...

9 days ago | 0

| accepted

Answered
i want to make a for loop that goes like this for a=0:1:180 && 179:-1:-180 but it is not possible in matlab, any ideas how to do it?
It is not clear to me what you really want. Maybe this? for a=[0:1:180,179:-1:-180] % whatever end

9 days ago | 0

| accepted

Answered
need a help using loop
You have learned the hard way one of the first lessons of good programming practice ... don't create a bunch of variables with t...

9 days ago | 0

Responded


Re: Uncomment shortcut on Matlab
Does Ctrl-t work to uncomment a block of code? (And Ctrl-r for commenting) James Tursa

10 days ago | 212 views

Answered
How to confirm user input is a word based on ascii table?
Like this? prompt = 'Enter word '; while( true ) answer = input(prompt, 's'); if( all(ismember(answer,'AB...

10 days ago | 0

Answered
Question about machine epsilon
The short answer is that the result is rounded. How this rounding takes place is going to depend on the rounding modes available...

11 days ago | 2

| accepted

Answered
Improve efficiency of backslash operator for sparse matrices
You might find something in Tim Davis FEX submissions that would help: http://www.mathworks.com/matlabcentral/fileexchange/?t...

11 days ago | 0

Answered
matlab code to make values of an array in specific ranges(index positions) equal to zero
for k=1:numel(start_index_positions) d(start_index_positions(k):end_index_positions(k)) = 0; end

11 days ago | 0

Load more