Answered
How to create a random row vector whose sum of elements and number of elements is at my desire?
n = 5; m = 20; a = rand(n,1); out = round(a/sum(a)*m); out(1) = out(1) - sum(out) + m;

12 years ago | 1

| accepted

Answered
How to use the index ? how to drop elements from a matrix ?
b = [0.0913 NaN NaN NaN 0.0913 NaN NaN NaN 0.0913 ...

12 years ago | 0

Answered
How to substitute multiple values in symbolic matrix?
syms x y z w N=[ w+y+z,x/2 - y/3 + z/3, x*y, x+z] X = sym(['[',sprintf('X(%d) ',1:4),']']) out = subs(N,[x, y, z, w],...

12 years ago | 4

| accepted

Answered
How can I express a symbolic variable in function of other symbolic variables,
syms x y z xfun = matlabFunction(solve(x^2+y^3 == z,x))

12 years ago | 0

Solved


Insert certain elements into a vector.
We start with vector V. Some values W will be inserted into V, at positions U. Say, |V| contains |[1 2 3 4 5]| and |W| is |[0...

12 years ago

Solved


Length of a short side
Calculate the length of the short side, a, of a right-angled triangle with hypotenuse of length c, and other short side of lengt...

12 years ago

Answered
How to pick the elements in a vector with row coordinates satisfying a criterion determined by another vector?
[ii,ii]=unique(A,'last'); C = B(ii);

12 years ago | 0

| accepted

Answered
HOW TO SOLVE THIS FUNCTION?
Please read about |dsolve| : doc dsolve Your case: syms x y(x) yy = dsolve(diff(y) == -2*y + 2*x^2 + 2*x, ...

12 years ago | 0

Answered
How to concatenate multi rows in matrix ?
y = 1:6; o = reshape(bsxfun(@times,kron(fliplr(~eye(3)),[1 1]),y)',1,[]); out = repmat(reshape(o(o~=0),4,1,[]),1,7); ...

12 years ago | 0

Answered
how to generate random variables with gaussian distribution with 0 mean and 1 standard deviation.
See <http://www.mathworks.com/matlabcentral/answers/107013-zero-mean-and-one-variance answer> by Roger Stafford. Example: ...

12 years ago | 0

Answered
remove the repeating values in array
a = [ 29 29 29 29 25 25 29 29 27; 13 13 13 13 14 14 13 13 19]; [ii,ii] = unique(a','rows','first') out = a(:,so...

12 years ago | 2

| accepted

Answered
How do I horizontally concatenate the following 2 numerical arrays?
out = [ND(OD(:,2),:),OD]

12 years ago | 0

Answered
Eliminate duplicates of nonzero elements but keep zeros
A(~([false,diff(A)] == 0 & A == 1))

12 years ago | 0

Answered
how we can select 2 or more variables from an array depending on their values.
[value1,index1] = sort(A,'descend'); out = [value1(1:4),index1(1:4)];

12 years ago | 0

| accepted

Answered
Create a matrix with same diagonal elements
out = tril(toeplitz(x));

12 years ago | 0

Answered
Open and read monthly dataseries with the filename 'yyyymmdd'
Try this is code: StartDate = 20100502; EndDate = 20160201; v = datevec([sprintf('%d',StartDate);sprintf('%d',EndDate...

12 years ago | 0

| accepted

Answered
I have them matrix a=[2 5;4 6;5 1; 5 2; 5 7;10 3;10 4],I want it to be a=[2 5 0 0;4 6 0 0;5 1 2 7;10 3 4 0]
see your <http://www.mathworks.com/matlabcentral/answers/107511-i-have-the-matrix-a-5-5-10-10-2-4-5-i-want-the-result-to-be-d-5-...

12 years ago | 0

Answered
Transforming Timestamps column into various columns
data = {'01/01/2012 09:00' '01/01/2012 10:00' '01/01/2012 11:00'}; v = datevec(data); out = v(:,1:4);

12 years ago | 0

| accepted

Answered
To Run a program for multiple times for different data and report result for each run
n = 10; % let number of your .asc files outdata = cell(n,2); t=0:1:1000; figure; for jj = 1:n nme = sprintf...

12 years ago | 1

| accepted

Answered
How can I add the average of two consecutive numbers?
y = randi(10,5,1); Area = sum(conv2(y,[1;1]/2,'valid'));

12 years ago | 0

Answered
I have the matrix a=[5 5 10 10 2 4 5],I want the result to be d=[5 1 2 7;10 3 4 0;2 5 0 0;4 6 0 0],
[a1,b,c] = unique(a(:),'first') [~,ii] = sort(b); a1 = a1(ii); c = ii(c); n = max(histc(c,(1:max(c))')); f1...

12 years ago | 0

Answered
Element-By-Element Operations using Matlab
u*min(0,A*x-b).^2;

12 years ago | 0

| accepted

Answered
Search in array with sequence
out = sprintf('%d',strfind([y '0'],'10')-strfind(['0' y],'01')+4) ADD out = sprintf('%d',(strfind([y '0'],'10')-strfin...

12 years ago | 0

Answered
How to divide a data arry into blocks like this using a FOR loop?
a = -1-j; b = 2-j; data = a+(b-a)*rand(1,256); m=[1,2,4,8,16]; s = numel(m); k = numel(data)./m; out = cel...

12 years ago | 0

Answered
How to replace a for loop with something faster
Please try is it: p1 = phi.*r; p2 = phi.*(lam_+g_)-.5*g_^2; p3 = .5.*(phi-g_).^2; a2 = 2*a; for ii = 1:T-1 ...

12 years ago | 0

Answered
CALCULATION SUBSTRINGS OF MATRIZ SEQUENCES
s = [0 1 1 0 1 1 0 1 0 0 0 1; 0 1 1 1 1 1 0 1 1 0 0 0]; sz = size(s); k = 4; s1 = s'; idx = bsxfun(@plus,ha...

12 years ago | 0

| accepted

Answered
SUBSTRINGS CREATION WITH DIFFERENT ORDER
s = [0 1 1 0 1 1 0 1 0 0 0 1 ]; n = numel(s); k=4:n; out = cell(n-3,1); for jj = 1:numel(k) p =...

12 years ago | 0

Answered
How to find the x value corresponding to the half of a curve?
S - your signal; time1 - time. [a,ia] = max(S); l1 = [false;diff(S(1:ia)) < 1]; ib = find(l1,1,'last'); b = S(ib...

12 years ago | 0

Answered
How to repeat rows of a matrix n times when n varies with each row?
CC=zeros(size(A,1),6); i2 = cumsum(C(:,6)); i1 = i2 - C(:,6) + 1; for ii=1:size(C,1) CC(i1(ii):i2(ii),:)=repma...

12 years ago | 1

| accepted

Load more