Community Profile

# James Tursa

##### Last seen: Today
3 366 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

RK4/AB4, need help with correct code for 2 second order equations in Matlab
So, first define a 4-element state vector. To keep the nomenclature the same as the MATLAB docs, I will use the variable name y....

ungefär 6 timmar ago | 0

Cell Arrays and Indexing?
This is the reverse of your last assignment. It needs only one loop over the number of rows, and the cell array element for tha...

ungefär 22 timmar ago | 0

| accepted

Cell arrays and Indexing with Cells HELP?
This row = Q(1:end); col = Q{1:end}; Z(row, col) = true; is actually a good attempt and shows you understand the problem .....

en dag ago | 0

| accepted

repeat the iteration with an error using try/catch
Maybe this construct does what you want while( true ) try MyProgramHere ...

en dag ago | 0

Storing doubles in the smallest integer class for which they fit without changing their value?
Some hints: Don't use loops, use vectorized code to figure out which integer size works. intmax(type) gives you the largest va...

en dag ago | 0

| accepted

How do I make a function work with vectors?
Use element-wise divide operator ./ (with the dot) instead of the matrix divide operator / (without the dot). E.g., tanH(x)=((...

en dag ago | 0

| accepted

Your basic problem is that you have two states, x and y, but your function arguments are inconsistent with this. Take this code:...

2 dagar ago | 1

| accepted

Really! fprintf cell error
What happens if you change this fprintf(fid, '%d %s %s %f',shape{i,:}); to this fprintf(fid, '%d %s %s %f',shape{i,1},shape{i...

2 dagar ago | 0

| accepted

MATLAB Homework Problem: "Incorrect use of '=' operator" in a for loop
This: for (i = 2:0.5:15 && j = -2:0.5:12) Needs to be two nested loops: for i = 2:0.5:15 for j = -2:0.5:12

2 dagar ago | 1

Homework help.(User defined functions )
Hint: See these functions: doc size doc isequal doc error

2 dagar ago | 0

| accepted

trouble understanding for loops
The first problem is getting the input from the user. This assigns a char string to pv: pv=('What was your original mortgage v...

2 dagar ago | 0

OR statement in a while Loop
Change to AND: while ((playerhp > 0) && (enemyhp > 0)) I.e., you only do the while loop when both hp are positive. It eit...

2 dagar ago | 0

| accepted

Fastest way to find the row number containing the most amount of black pixels in a gray-scale image?
[~,row_blackPix] = max(sum(image <= 20,2))

2 dagar ago | 0

| accepted

Varying step size for RK Method?
The only variable that depends on a new n is h, so only recalculate h and then run your loop as is. Although if you want to make...

3 dagar ago | 0

conversion from base 13 to IEEE 754
For the base 13 conversions: doc dec2base doc base2dec https://www.mathworks.com/help/matlab/ref/dec2base.html https://www.m...

3 dagar ago | 0

Whats wrong with my code? Taylor series Approx with error
You probably just need an absolute value error = abs((true-s)/true)*100; %Percent Error Formula That being said, true and erro...

4 dagar ago | 0

Functions and For Loops For Polynomials
Some guidance: 1) The sum=0 part needs to be moved outside the loop, prior to the loop starting. The way you have it the sum re...

4 dagar ago | 1

| accepted

How can I randomly select a subset of logicals?
T = your logical trials vector n = 20; % number of trials to keep f = find(T); % find the location of the 1's f = f(randperm(...

4 dagar ago | 1

| accepted

Custom help information on structure fields

4 dagar ago | 2

| accepted

Error using * Matrix dimensions must agree.
Change this piv=A(i:i); to this piv=A(i,i); And change this fac=A(j:i)./piv; to this fac=A(j,i)./piv;

4 dagar ago | 0

how to print multiple variables with strings in between ?
You could use fprintf. E.g. >> a = 5; >> b = 7; >> fprintf("Variable a equals: %g\n",a); Variable a equals: 5 >> fprintf("V...

4 dagar ago | 1

| accepted

Swapping last matrix columns
From your description, I don't see how your code works for anything other that inputs having two columns. I would guess that thi...

4 dagar ago | 0

C/Fortran callback to MATLAB
Maybe this can give you the framework you need. I have made some assumptions about how things are connected. You pass in a cha...

4 dagar ago | 0

| accepted

Common numbers between arrays
You could write some code using the intersect( ) function for this. E.g., the first result >> A = {[1,2,3], [3 4 5 6], [3 7 8 ...

4 dagar ago | 1

| accepted

How could I solve the problem of if statement for even and odd values?
mod(N,1) does not determine if a number is even or odd. You would want something like mod(N,2)==0 or mod(N,2)~=0. E.g., mod(Z...

4 dagar ago | 0

| accepted

Parse/Syntax Error
lamda**2 is Fortran. I presume you want lamda^2 instead

5 dagar ago | 0

How can plot every n-th element in a vector AND the last element?
If you don't care about possibly overplotting that last point twice, then simply n = 10; result = [p(n:n:end) p(end)]; If you...

5 dagar ago | 0

| accepted

element-wise exponential of matrix returns all 1s
Your calculations are sensitive to the input numbers. E.g., >> format longg >> thetas(1) ans = 12566.3706143592 >...

5 dagar ago | 0