Respondida
How to check if a user input is between a certain range
Use an "if test" combined with the results of the expressions z > 0 and z < 1 (or possibley z >= 0 and z <= 1 depending on what ...

más de 8 años hace | 0

Respondida
Accessing variables with functions in Matlab
To have a function change a variable in MATLAB, one would typically do this: x = myfunction(x); And then the body of myf...

más de 8 años hace | 0

| aceptada

Respondida
How to get the user to input numbers that will then go into an array?
You can use the input( ) function: <https://www.mathworks.com/help/matlab/ref/input.html?searchHighlight=input&s_tid=doc_srch...

más de 8 años hace | 0

Respondida
how can i generate real random numbers?
See this FEX contribution by John D'Errico: <https://www.mathworks.com/matlabcentral/fileexchange/49795-randfixedlinearcombin...

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

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

más de 8 años hace | 0

| aceptada

Pregunta


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

más de 8 años hace | 2 respuestas | 0

2

respuestas

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

más de 8 años hace | 0

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 2

| aceptada

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

más de 8 años hace | 0

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

más de 8 años hace | 0

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

más de 8 años hace | 0

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

más de 8 años hace | 1

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

más de 8 años hace | 0

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

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

más de 8 años hace | 1

| aceptada

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

más de 8 años hace | 1

| aceptada

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

más de 8 años hace | 0

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

más de 8 años hace | 1

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

más de 8 años hace | 0

| aceptada

Cargar más