Community Profile

James Tursa

3,134 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.

View details...

Contributions in
View by

how to plot euler forward method
Don't change the iteration variable withing the loop. Remove these lines from your code: n=1:11;

3 hours ago | 0

Creating a loop for game
The name "input" is an existing MATLAB function. It would be best to change this to something else, e.g. n. And use a differen...

3 hours ago | 0

# of elements mismatch
I'm guessing that the 97th element is empty. What does this show: tl{97}

23 hours ago | 1

| accepted

How to Convert Euler Angles (Z-X-Z Convention) to Axis Angles for Image Stack Rotation
An Euler Angle conversion routine by John Fuller that handles all possible conventions can be found here: https://www.mathworks...

1 day ago | 0

How to get field value from a struct as a variable in order to use in a code?
Depends on your downstream code whether this is really worth it, but simply e.g. x = yourstruct.x; y = yourstruct.y;

5 days ago | 1

Attempting to have a series for sin stop summing when the precision is correct
Inside the sinser function, you never set p to a vector ... it is always just a scalar. If you want to return all of those inte...

5 days ago | 0

generate unit vectors based on matrix size
Why not just V(1,2) = 1; Or if you really need to explicitly set those 0’s then start with V(:,2) = 0; followed by the above...

7 days ago | 0

| accepted

mod gives incorrect result

7 days ago | 1

| accepted

eulers improved method code error
s2=F(x+h/2,y+h*s1/2); %% is it correct for modified euler If "Improved" Euler's Method means "Modified" Euler's Method as your ...

7 days ago | 1

| accepted

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. What does this mean?
Look at this line: Segment(n_start)=data(n_start:(n_start+ window_size-1)); and simply plug in the numbers for the first itera...

7 days ago | 1

Getting an error with the ODE45 function.
You've got your calling code mixed in with your derivative code. You need to code this differently. E.g., one way: In a file c...

8 days ago | 0

| accepted

Runge Kutta method computational cost
Side Note, You should not be calculating f(x(k),t(k)) twice in your 2nd order method. You should be doing it like your 4th orde...

11 days ago | 1

Mex -largeArrayDims in Linux
You didn't give it the LAPACK library to link to, so there is no dgesv_ function, hence the error. You need to take this: lapac...

11 days ago | 0

Can MEX BLAS library be used for native double matrix in C?
Two problems: 2D matrices are stored column-wise by MATLAB and is assumed by the BLAS and LAPACK routines also. So this: ...

12 days ago | 1

| accepted

How to save ode45 outputs in a loop?
Don't use a loop. Just call ode45 once and it will give you the entire results in T and Y. [T,Y] = ode45(dydt, t, [y0, dy0]); ...

13 days ago | 0

Creating vectors by rand() and looping it
Good start, but do this to save the ceil function result back into vector: vector = ceil(vector); For the next part you need a...

19 days ago | 0

| accepted

How do I pull a value out of a different equation @ a specific value
[Tmin,k] = min(T); Dt = D(k);

19 days ago | 0

| accepted

Multiplying every secound element in a vector with -1
Or yet another of the zillion ways vny = v; vny(2:2:end) = -vny(2:2:end);

19 days ago | 1

Too many output arguments.
Why not just c = 2*x; d = 4*y;

20 days ago | 0

Don't do that. See this post for reasons why: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-sh...

20 days ago | 0

Trying to create a simple function Matlab gives me an error message
Put your vecout( ) function code in a separate file called vecout.m

20 days ago | 0

MATLAB indexing is 1-based, not 0-based. You will need to adjust your indexing: a(1) = 1; a(2) = 0; : etc

20 days ago | 0

Dimensions of arrays being concatenated are not consistent.
If they are all row vectors, then I would think something like this: Total_No_cells_r = [Total_No_cells_r, total_cellcount_r]; ...

20 days ago | 0

Extract integer number from a cell array.
You could do this: C = your cell array of strings, some containing numbers d = str2double(C); d = d(~isnan(d));

21 days ago | 0

Why is the inv function not working in this code (simple)
Best to put commas in your matrix difinition so that the parser doesn't inadvertently combine things that you didn't want. E.g.,...

21 days ago | 1

| accepted

(ODE45) Unable to perform assignment because the left and right sides have a different number of elements
It might be simpler to have separate files for this. Put this code (and only this code) in a file called HW4_matlab.m %% Solvi...

21 days ago | 0

Precision in calculation of large digits
You need to convert to vpa first so that the factorial calculation is done with extended precision. factorial(vpa(97))

21 days ago | 2

Attempting to completely fill out an array(6,7) with 1's and 2's for connect4
Maybe you could explain what your code is supposed to be doing. Commenting the code would be great. But if you just want a boa...

25 days ago | 0

not enough argument input
You need to put your function code into a file called dew_point.m Then you need to call your function with inputs, e.g. T = so...

25 days ago | 1