답변 있음
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...

대략 6년 전 | 0

| 수락됨

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

대략 6년 전 | 0

| 수락됨

답변 있음
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년 전 | 0

답변 있음
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년 전 | 0

| 수락됨

답변 있음
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년 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 1

| 수락됨

답변 있음
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년 초과 전 | 1

| 수락됨

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 1

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 1

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 1

| 수락됨

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 1

| 수락됨

답변 있음
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년 초과 전 | 1

| 수락됨

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 1

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 1

더 보기