Answered
How to find max value and divide it in two rows
X = [66 101 1050 1200 66 102 1200 1370 66 106 1370 1450 67 103 1050 1060 67 105 1060 1190 67 105 1190 1450 6...

9 years ago | 0

Answered
How to draw (random or with certain chance) multiple elements from a set where the element must not be equal to each other
V = [1 2 3 4 5 6]; A = nchoosek(V,3); strategies = A(randperm(size(A,1),10),:);

9 years ago | 0

| accepted

Answered
Logical Indexing one vector using a second vector
Vectors = bcxfun(@eq,Trial_Index(:),TrialNumbers(:).');

9 years ago | 0

| accepted

Answered
How is the following code correct? Shouldn't answer be zero as g matrix will give zero on element wise division?
sigmoid = @(z)1./(1+exp(-z)); use >> sigmoid = @(z)1./(1+exp(-z)); >> sigmoid(0:5) ans = 0.5000 0....

9 years ago | 0

Answered
Fill matrix randomely without row-repetitions
A = [1 1 1 2 2 2 3 3 3 4 4 4 5]; result = nan(8,12); result(1:numel(A)) = A; [~,ii] = sort(rand(8,12),2); resu...

9 years ago | 0

Answered
How can I add values from a second column if the value in the first column is the same?
a = [1 2 1 5 2 6 3 4 3 3 3 8]; [G,aa] = findgroups(a(:,1)); out = [aa,splitapply(@sum,a(:,2),G)

9 years ago | 0

| accepted

Answered
How to use if inside loop
RY = 1:200; L_B = 40; L_S = 20; LL = [L_B;L_S]; r = repelem((1:3)',2); lgt = 2*toeplitz([0;r;4],[0 0])*[L_B...

9 years ago | 0

Answered
Extracting columns from a matrix with a matrix
B = randi(10,6,8); A=[0 3 0; 0 2 1]; X = num2cell(sum(reshape(B(:,A+1),size(B,1),size(A,1),[]),3),1);

9 years ago | 0

| accepted

Answered
How to input this finite element analysis matrix in matlab?
example: create of A vector ne = 7; L = 0.5; dx = L/ne; x = (dx:dx:L)'; A = pi* (0.03-0.017455*L+0.01745...

9 years ago | 0

Answered
Auto fill zero matrix without row-repetitions
m = 5; n = 3; A = reshape(test,n,m)'; out = A(bsxfun(@plus,hankel(1:m,[m,1:n-1]),m*(0:n-1))); out = out(randperm(m...

9 years ago | 0

Answered
How to keep the values from every loop that solves a system in a single matrix?
syms cg1 cg2 cp1 cp2 x1 drog eqn1=cg1+cp1==0.05*drog; eqn2=cg2+cp2==0.15*drog; eqn3=cg1==(132.24/(0.082*298))*x1; ...

9 years ago | 0

Answered
How can I subtract certain values from a matrix depending on another matrix?
r = [6 10 12;8 5 4;9 8 12] p = [4 8 13;8 5 5;1 2 0] d = [5 10 15]' [~, ord] = sort(d, 'descend'); out = p; out(...

9 years ago | 1

| accepted

Answered
how to solve two functions with matlab
syms x y eqn = [10.0686*x*y==2*x^2+2*x*y^2-4*x-4*y-5*x^2-1.6667*y^2 -15.7708*x*y== 4*x+5*x^2+0.0841*(x^2*y+x*y^2)+4*y+1....

9 years ago | 1

Answered
String Replacing for a DNA sequence
A = {'AAGC', 1 ;'GCCU', 2 ;'AGCU', 2; 'CCGU' 1}; T = cell2table(A,'var',{'DNA','count'}); Tout = T(T.count > 1,:);

9 years ago | 0

| accepted

Answered
Delete every n rows if less than x
Let |A| - your array [m x 14] ii = ceil((1:m)'/24); l0 = accumarray(ii,A(:,5) >= x,[],@all); out = A(l0(ii),:);

9 years ago | 0

Answered
Find the elements in matrix that are not within the specified range
a = [232 209 237 241 226 233 237 229 235 205 215 205 227 227 219 227 240 227 242 221 238 245 205 234 2...

9 years ago | 0

Answered
find the area enclosed under the curve
out = trapz(vd_f,id_f); other out = integral(@(vd_f)is * (exp((q * vd_f)/(k * tk)) - 1),vd_f([1,end]));

9 years ago | 0

Answered
date computations in a table
LC.date = datetime(sprintfc('%d',LC.date),'InputFormat','yyyyMMdd'); LC.month_year = [month(LC.date),year(LC.date)]

9 years ago | 0

| accepted

Answered
How to sum some columns of a matrix?
B = blockproc(padarray(A,[0,1],0),[1,2],@(x)sum(x.data,2))

9 years ago | 1

Answered
How to insert values to specific locations in a matrix
lon=-145:0.1:-144; lat=45:0.1:46; aa=[-144.9 -144.8 -144.6 -144.5 -144.3 -144.2]; bb=[45.0 45.1 45.6 45.7 45.9 46.0];...

9 years ago | 1

| accepted

Answered
How to integrate matrices?
>> t = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]; %time = 1x20 heatflux = [2 3 5 7 9 11 12 13 14 19 24 14 12 13...

9 years ago | 3

| accepted

Answered
Finding the repeated substrings
A = 'AAGTCAAGTCAATCG'; B = hankel(A(1:end-3),A(end-3:end)); [a,~,c] = unique(B,'rows','stable'); out = table(a,accuma...

9 years ago | 2

Answered
How can I solve A*X + X*B = C equation for X? where A, B&C are 2*2 matrixes.
>> A = [1 1;2 3]; B= [5 6;7 8]; C = [11 12;13 14]; X = reshape(sym('x',[4,1],'real'),2,[]); v = A*X + X*B ...

9 years ago | 1

Answered
Creating a matrix where each row is the average of rows of another matrix.
One way: a = [... 102 20 114 122 16 120 115 61 80 101 13 18 ...

9 years ago | 1

Answered
How do you determine the average values in second column of a matrix if values in first column are equal?
a= [0.4000 0.5000 0.4000 0.4500 0.4000 0.6000 0.6000 1.0000 0.6000 1.2000 1.2000 3.0000 1.2000 3.5000 1.2000 3.0000]; ...

9 years ago | 2

| accepted

Answered
How can I get the maximum value between continuous non-zero numbers for the following vector A?
A=[0 0 0 0 5 2 0 2 2 3 0 4 2]; t = A ~= 0; ii = cumsum(diff([0;t(:)]) == 1); out = accumarray(ii(t),A(t),[],@max)...

9 years ago | 1

Answered
How to write a program to draw a diamond of stars in MATLAB?
n = 7; m = ceil(n/2); ii = toeplitz([ones(m,1);zeros(n-m,1)]); out = repmat(' ',n); out(ii & rot90(ii)) = '*'

9 years ago | 0

Answered
i have a mxn matrix. I have to use a 3x3 mask to compare the center value with all 8 neighborhood values and put a threshold to the difference (above which the center pixel has to be replaced with 0)
use functions |imdilate|, |imerode| from |Image Processing Toolbox|: f = @(x)abs(x(a,[1 1 1 ;1 0 1;1 1 1]) - a) <= 2; b...

9 years ago | 0

| accepted

Answered
I need someone to help me vectorize the following nested loops
Let |g = gamma|: story = g(:)'*(1 - min(1,(1:numel(g))'*m(:)'/n))*p(:);

9 years ago | 0

| accepted

Load more