Respondida
Am I doing this right? (a Math formula to Matlab language)
You are on the right track, but have typos in the code due to parentheses issues. A = sum( (x - y).^2 ); B = sum( (x - mean(x)...

más de 6 años hace | 1

| aceptada

Respondida
Numerical solution of Higher order differential equation using ODE45 and a m. archice
t is a number, not a symbol. So u = sin(t) is a number, not a symbolic function. So doing diff(u) does diff on a single value,...

más de 6 años hace | 0

| aceptada

Respondida
Write an executable script file (m-file) that takes no inputs and returns the displacement and stored energy of a spring system after prompting the user for the 1) input forces (in N) on the spring and 2) the spring constant (in N/m).
To get you started, simply create an m-file with something like this at the front end: F = input('Input the force on the spring...

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

| aceptada

Respondida
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 ...

más de 6 años hace | 0

Respondida
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)

más de 6 años hace | 0

| aceptada

Respondida
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...

más de 6 años hace | 0

| aceptada

Respondida
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...

más de 6 años hace | 0

Respondida
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,:);

más de 6 años hace | 1

| aceptada

Respondida
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) +...

más de 6 años hace | 1

| aceptada

Respondida
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...

más de 6 años hace | 0

| aceptada

Respondida
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...

más de 6 años hace | 0

Respondida
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.

más de 6 años hace | 0

| aceptada

Respondida
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 ...

más de 6 años hace | 0

| aceptada

Respondida
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...

más de 6 años hace | 1

Respondida
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...

más de 6 años hace | 0

Respondida
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

más de 6 años hace | 0

Respondida
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...

más de 6 años hace | 0

Respondida
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...

más de 6 años hace | 0

Respondida
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...

más de 6 años hace | 0

| aceptada

Respondida
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...

más de 6 años hace | 1

Respondida
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...

más de 6 años hace | 0

Respondida
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...

más de 6 años hace | 1

| aceptada

Respondida
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...

más de 6 años hace | 0

| aceptada

Respondida
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.

más de 6 años hace | 1

| aceptada

Respondida
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...

más de 6 años hace | 1

| aceptada

Respondida
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...

más de 6 años hace | 0

Respondida
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';

más de 6 años hace | 1

Respondida
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...

más de 6 años hace | 0

Cargar más