Question

I have problem writing a matlab function

I want to write this function in matrix form. The function is I defined the vector as: Then what is wrong with my code? fu...

1 year ago | 3 answers | 0

Question

A question about sorting a vector

Suppose I have a column vector V of length N and I map every element in V to an element y in Y so, we have a column vector Y of ...

1 year ago | 1 answer | 0

Question

How to find the position of an element in a vector

Hello, Is there a function in matlab that takes a column vector of n rows and a number as an input and returns its position ...

1 year ago | 2 answers | 0

Question

How to generate a random integer between two bounds?

Hello, I want to generate a random integer between two integers Suppose the upper bound UP=500 and the lower bound LB=4 how ...

1 year ago | 1 answer | 0

Question

Why the function "bi2de" only returns non-negative integers, when the description says it returns non-negative real numbers!

I read that the function bi2de takes any binary vector - "a vector composed of only zeros and ones" and returns a non-negative r...

1 year ago | 1 answer | 0

Question

Why does matlab return "Index exceeds matrix dimensions"?

Hello, Nind=2; %number of vectors Nvar=2; %number of variables in each vector perci=3; %number of bits of every variable p...

1 year ago | 0 answers | 0

Question

A question about the simple genetic algorithm code

This is a code I found of the genetic algorithm. I am a beginner in MATLAB but I really would like to understand the code. The C...

1 year ago | 0 answers | 0

Question

Given a column matrix of numbers, how to extract some numbers that meet some condition and save them in a new matrix, if I don't know how many numbers will meet the condition?

Suppose I have a matrix R of n rows and 1 column, suppose I want to extract all numbers from matrix R that are less than or equa...

1 year ago | 1 answer | 0

Question

Error: The first argument must be a scalar.

I defined a matrix of variables like this X=sym('X', [4,1]) %it looks like this X=[X1 X2 X3 X4]' Then the code did some stu...

2 years ago | 1 answer | 0

Question

Loop over non-numeric stuff

Hello, I defined a vector of variables in my code like this x=sym('x', [m,1]) then I defined a matrix M as follows M=zeros(m...

2 years ago | 0 answers | 0

Question

I have an idea that I want to write in MATLAB language

I am trying to write a MATLAB code that does the following the user should enter 3 vectors (x1, x2, x3) each has 2 components th...

2 years ago | 1 answer | 0

Question

Need some help with a while loop

x0=[0.8 0.8 0.2 0.2]'; tol=1e-6; m0=[0.5 0.5]'; syms x y z p m1 m2 h1=y-(x^3)-(z^2); h2=(x^2)-y-p^2; h=[h1 h2]'; f=-x; ...

2 years ago | 1 answer | 0

Question

Something is wrong in my line search gradient descent code. It gets stuck!

x0=[10 5]'; x0=[10 5]'; tol=1e-6; syms x y f= (1/2)*(x^2)+(9/2)*(y^2); g=gradient(f, [x, y]); g0=subs(g, x, x0(1,1)); g0=...

2 years ago | 1 answer | 0