Answered
How can I add 1 to a particular element in a matrix?
M = your 13x13 matrix M(1,2) = M(1,2) + 1;

6 years ago | 0

| accepted

Answered
How to determine Simplex using Nelder-Mead Algorithm in all direction?
The Nelder-Mead Simplex Method is an adaptive method that adjusts the lengths and directions dynamically. The vertices could be ...

6 years ago | 0

Answered
Question on why tilde cannot return the opposite statement result
Precedence of ~ is hgher than >, so it gets performed first. You need to use parentheses: ~(adultdata.age>50)

6 years ago | 0

| accepted

Answered
A single column vector or an array, which is faster?
Other things you are doing in your code are likely to dominate run times. We would need to see your particular application to of...

6 years ago | 0

| accepted

Answered
Matrices and indexing ?!
[LX,LY] = ndgrid(Lx,Ly); z = LX(:)./LY(:) <= 2; LX = LX(z); LY = LY(z); LX and LY contain the number pairs that match the co...

6 years ago | 0

Answered
Sort rows of matrix by matching column with another matrix column
E.g., assuming everything in column 31 has a match [~,x] = ismember(A(:,31),B(:,31)); Bsort = B(x,:);

6 years ago | 1

| accepted

Answered
how to find max value of a function with a for loop
Make e a vector. E.g., for i=1:length(x) e(i) = y(i) - (m*x(i)-b); % <-- Are you sure that isn't supposed to be (m*x(i) +...

6 years ago | 1

| accepted

Answered
How to solve a system of ODEs and plot the result
This is where you needed to show us the complete code and the complete error message. It is probably complaining about your init...

6 years ago | 0

| accepted

Answered
precision of calculation with Matlab
Calculators may not use the same floating point representations or arithmetic routines that MATLAB uses, so differences in the t...

6 years ago | 0

Answered
How to code for this equation in Matlab
Assuming that f(x) is really supposed to be f(t): f = @(t)exp(j*w*t); But, you will need to have w defined prior to this.

6 years ago | 0

| accepted

Answered
Mex C file generation Linker library error
Do you already have a zzz.lib file? Normally to get your mexFunction code to link to the library you simply include it as part ...

6 years ago | 0

| accepted

Answered
rand command give different answer
rand( ) is a random number generator ... it is supposed to give a different result. doc rand If you want to start over with th...

6 years ago | 1

Answered
Help creating an array to hold approx error from a taylor series
Generally, just index into your variable inside the loop: a_values(index) = a_err; If the indexing could be large, you would a...

6 years ago | 0

Answered
What is the Aerospace Blockset quaternion convention?
See also the Answer in this post: https://www.mathworks.com/matlabcentral/answers/465053-rotation-order-of-quatrotate

6 years ago | 0

Answered
angle between three points (in 3D)?
See the discussion in these links: https://www.mathworks.com/matlabcentral/answers/101590-how-can-i-determine-the-angle-between...

6 years ago | 0

Answered
How to convert char to uint8 and vice versa without changing the underlying data
Simply: c = original char array u = uint8(c); Or u = original uint8 array c = char(u); If you mean you want to reinterpret...

6 years ago | 0

Answered
Multiplying each column of a matrix with a specific value
mat=[2,1,0,0;1,0,0,0;0,0,0,1]; % 2D matrix f = [25,5,10,1]; % row vector result = f .* mat; % element-wise multiply with virtu...

6 years ago | 0

| accepted

Answered
Creating Unit vectors in a loop
Since a complete answer has already been posted, I will post this one using a cell array result which will be much easier to ind...

6 years ago | 1

Answered
When i run this code i get error using dec2bin (too many input arguments).
MATLAB is case sensitive. Text (uppercase T) is different from text (lowercase t). In the future, please post the complete erro...

6 years ago | 0

Answered
Maclauren Series Iteration. Answer provided just having trouble getting code to run properly
Some issues: 1) This line: new_cos=(old_cos-(x^n))/(factorial(n)); You are dividing the old_cos by the factorial(n). This do...

6 years ago | 1

| accepted

Answered
Model a simple circular satellite orbit in time
Since you are setting up a circular orbit, just scale the time by the period to get theta. E.g., since one period would be an an...

6 years ago | 0

| accepted

Answered
Question: Create a function that takes a generic matrix, x, and finds the smallest value in the matrix.The function must work for matrices of any size and dimension.
Hint: First reshape the input x array into a 1D vector and work with that inside your function.

6 years ago | 1

| accepted

Answered
How to wrap on overflow when transfer a double to integer
You could use: y = mod(x,double(intmax('uint16'))+1); But, if x is too large so that eps(x) > 1 the result might be somewhat m...

6 years ago | 1

| accepted

Answered
Finding all multiples of 5 or 7 from 1 to 10000 with a loop.
An basic outline of the for loop to get you started: n = 10000; % the limit of the for loop x57a = []; % initialize the result...

6 years ago | 0

Answered
What type of function Matlab has help to construct symmetric matrix?
If no specific properties needed, then you could use n = the desired size M = rand(n); M = M + M';

6 years ago | 1

Answered
Matrix dimensions must agree error in FOR loop
This comparison: z == 'no' compares z to a 1x2 array. And this comparison z == 'yes' compares z to a 1x3 array. So you are...

6 years ago | 0

Answered
Calling C functions using MATLAB.
This: void (*camp)(double x, double *y, int n, double *f) is not a function as you claim. It is a pointer to a function that ...

6 years ago | 0

Answered
Can't figure out what I am doing wrong. Looking to find square root using the equation given x=(x+x/a)/2. I also feel like I am not making use of the approximation errors ea and es.
You can't do these assignments in this order: x_old=x; ea=((x-x_old)/x)*100; The first one will cause the second one ...

6 years ago | 1

Answered
Coupled second order ODE with three variables
Problems: 1) Units. You really should annotate ALL of your constants with descriptions and units so that the reader knows what...

6 years ago | 0

Load more