Answered
How to convert a column matrix 200 X 1 to a matrix 10 X 20 mat lab
Either result = reshape(your_matrix,10,20) or this result = reshape(your_matrix,20,10).' depending on how you wa...

8 years ago | 0

| accepted

Answered
How to store a number with its leading zeros?
Another way: x = your numeric number the_digits = sprintf('%09d',x)-'0';

8 years ago | 0

Answered
"must return a column vector" ODE45
The derivative function needs to return a derivative column vector at a single point in time, not construct an array of such der...

8 years ago | 0

| accepted

Question


Infinite Recursive Property Assignment
I am writing code to process all of the variables in the workspace to see which ones are shared with each other. Suppose I defin...

8 years ago | 2 answers | 0

2

answers

Answered
How to extract the second row of a 2x1 matrix?
M = your two-row matrix M1 = M(1,:); % 1st row of M M2 = M(2,:); % 2nd row of M However, in many cases it is better t...

8 years ago | 0

Answered
Find the angle between 2 planes made by x-y axis of 2 coordinate systems
For the generic solution, get a normal vector for each of the planes and find the angle between those. E.g., conceptually, ...

8 years ago | 0

| accepted

Answered
How can I use Euler's method to solve this ODE problem in MATLAB?
Looks like you have been given the complete integrator code, and all you need to do is define the derivative function f. Althou...

8 years ago | 0

Answered
More efficient alternative to the find function?
It is not clear from your post if A always has the pattern you show, but if it does then why not just this: F = [current-1,...

8 years ago | 0

| accepted

Answered
how i can sum only positive number in each row of matrix?
result = sum(A.*(A>0),2);

8 years ago | 0

| accepted

Answered
Insert efficiently elements into sorted array
Here is a mex routine to do the operation in case you are interested. It runs in about 1/2 the time of the m-code on my machine....

8 years ago | 2

| accepted

Answered
When using matlab, you can actually divide a scalar by column vector and produce a result; how does Matlab execute this?
You are using two different operators, the ./ operator which is element-wise division, and the / operator which is matrix divisi...

8 years ago | 0

Answered
Not enough input arguments. Error in myfun (line 2) x=x(1);
This will not do what you want: x=x(1); y=x(2); The moment you execute the first line, the entire variable x is repla...

8 years ago | 0

Answered
How do I make a generic function?
Here is how you start: Use the editor to make a file. Suppose you wanted the function called myfun. Then use the editor to star...

8 years ago | 0

Answered
How to place NaN at diagonal position in cell array?
Assuming there are at least as many columns as rows: [m,n] = size(a); out = cell(n+1,m); x = logical(eye(size(out)));...

8 years ago | 1

Answered
Write a 'for' loop from 1 to 3 using 'i' as the variable. For each value of 'i', create a vector 'x' and vector 't' to plot.
Move the plotting and "hold on" inside the loop. For the t vector, the instructions did not say "random", so probably what was m...

8 years ago | 0

Answered
plus or minus calculation
Maybe something like this is what you need: if( all(abs(your_value - your_vector) <= 0.25) ) % etc end

8 years ago | 0

| accepted

Answered
Transform array to matrix
Hint: Look at combining the results of A(1:end-1) and A(2:end) into your resulting matrix.

8 years ago | 0

| accepted

Answered
Using a for loop how can I add the sum of all the even digits in a 4 digit number
Hints: Look at the num2str( ) function or the sprintf( ) function. Take the output of that, figure out how to turn the character...

8 years ago | 0

Answered
Not outputting all the values for Euler's formula
Just use indexing to pick off the elements you want to display. E.g., disp(h0_5(1:2:end)); : disp(h0_25(1:4:end))...

8 years ago | 0

| accepted

Answered
Count number of values greater than a certain value in 3d matrix
result = sum(myarray>=10.5,3);

8 years ago | 0

| accepted

Answered
HELP ME PLEASE! How to find parameter estimation with fminsearch? And solve it with ode45? Why it always error when i run my codes?
Your function signature is: function dydt = fungsi(t,y,p) But your function handle signature is: fun = @(p)fungsi(p...

8 years ago | 0

Answered
Determine which of N points is not on sin(ax+b), where a and b are unknown.
A modification of your posted approach: Calculate the a and b using two points at a time, then use that to generate an associ...

8 years ago | 1

| accepted

Answered
Insert an array into another array
You can't do this with double class variables, where you are limited to one value per element. But you could use a cell array fo...

8 years ago | 1

| accepted

Answered
ode45 no enough input argument
The error in this line: Error in funsystest (line 12) phi2=[x(1),sin x(2)]; As you can see, the sin is all by itself wit...

8 years ago | 0

Answered
Solve a symste of 2nd order ODE using ode45
1st order ODE means your state vector will have 1 element. 2nd order ODE means your state vector will have 2 elements. Two...

8 years ago | 1

Answered
When I run the below code, why dont I get value of Q=[ 2 3]
Your fundamental problem is that asin( ) is multi-valued and you are treating it as single-valued. To recover the 2 and 3, you w...

8 years ago | 0

| accepted

Answered
Find the rational number k for which the matrix A= [1 2 k;3 -1 1;5 3 -5] is singular (iff the determinant is 0).
Hint: The matrix A will be singular if the first row [1 2 k] is a linear combination of the other two rows [3 -1 1] and [5 3 -5]...

8 years ago | 0

| accepted

Answered
modular operation in matlab?
Assuming you mean 2750 = mod(x,7829), there are infinitely many solutions: x = 2750 + n * 7829, for any integer n

8 years ago | 0

| accepted

Answered
MATLAB error: Output argument "variable" (and maybe others) not assigned during call to "function".
It appears that the 5th output argument, dec, isn't always necessarily assigned by your function. It is only assigned if the co...

8 years ago | 0

Answered
Requires More Input Arguments
_"...Requires More Input Arguments..."_ usually means you didn't call the function with enough input arguments. E.g., you could ...

8 years ago | 0

| accepted

Load more