Answered
how can I generate different vectors with the all the unique combinations of numbers inside a one vector?
a=[1 2 3 4] r = cell; for ii = numel(a)-1:-1:1 r = [r;num2cell(nchoosek(a,ii),2)]; end

10 years ago | 0

| accepted

Answered
How to extrapolate gridded matrix?
use |scatteredInterpolant| Hs = [4.9573 6.6098 8.2622 9.9147 13.2196 16.5245 24.7868 33.0490]; Uw = [1.12 2.4500 4.4...

10 years ago | 1

| accepted

Answered
QUESTION ON MATRIX RESHAPING
a = reshape(1:9,3,[])'; out = kron(a,ones(3)); or out = repelem(A,3,3)

10 years ago | 0

| accepted

Answered
What changes should I make to save the values of P? P should at least be a 2×2 matrix!!
n = (1:2:19)'; t = n*pi/b; P = [n, cumsum(c*sin(t*x).*sinh(t*y)./sinh(t*a)./n)];

10 years ago | 0

Answered
Find the First element that satisfies a condition
t = A < 5; x = cumsum(t,2) == 1 & t; out = sum(x.*A,2); out(~any(t,2)) = nan idx = x*(1:size(A,2))'

10 years ago | 3

Answered
How can i optimize my code without a for-loop ?
R = bsxfun(@minus, r_source, r_rec); sqr1 = 1./sqrt(sum(R.^2,2)); r1 = bsxfun(@times,R,sqr1); r2 = 3*r1(:,3)*m0; ...

10 years ago | 0

Solved


Fill the Matrix - 2
Input is a column vector and n. n columns will be added to the left of the input column. The first value of the row is the me...

10 years ago

Solved


Fill the matrix - 1
Input is a column vector and n. n columns will be added to the left of the input column. The first value of the row is the s...

10 years ago

Answered
Minimum of unique values
[~,~,c] = unique(x); z = accumarray(c(:),y(:),[],@min);

10 years ago | 0

Solved


Is my wife really right?
For every input, output the string 'yes' once. Example: [yes1, yes2] = YesSheIs('Am I right?', 'Do you love me?') yes1 = '...

10 years ago

Solved


Find the next square number
Given one or more integers n, find the next integer that is a square, for each of them. Example 1: n = 1; out = 4; ...

10 years ago

Answered
On vectorizing a function that takes vectors and scalars as inputs
XY -> array (X,Y) coordinates with size [m X 2]; XY0 -> array (X0,Y0) with size [n X 2] out = squeeze(bsxfun(@hypot,XY...

10 years ago | 0

| accepted

Answered
Downsampling by Averaging in Blocks
y=[1,2,3,4,5,6,7,8,9,10,11]; out = nanmean(reshape([y(:); nan(mod(-numel(y),4),1)],4,[]));

10 years ago | 7

| accepted

Answered
Counting program every positive element
Let date1 - arrey with your dates, DATA - your data f = fopen('kwazi_data_1993.txt'); c = textscan(f,'%s','delimiter','\...

10 years ago | 0

Answered
Impor text file: starting from the first row of numbers
f = fopen('filebyYoulin.txt'); c = textscan(f,'%s','delimiter','\n'); fclose(f); str = regexp(c{:},'\d*\.\d*','ma...

10 years ago | 0

Answered
How do I avoid using for loop when I want to treat the rows of a matrix individually?
B=[1 2 1 3;1 2 1 4;1 3 1 4;1 2 1 6;1 4 1 5;1 5 1 3;1 5 1 7]; A=[1 2;1 5]; D=[1 3;1 4;1 5;1 6]; [lo,ii] = isme...

10 years ago | 0

Answered
Help with for loop indexing
st = ' he who sees and he who is not '; a = regexp(st,'\w*','match'); outStr = strjoin(a(cellfun(@numel,a)>2),' ');

10 years ago | 0

Answered
Solving a matrix (bidiagonal) in MATLAB
X = A\B

10 years ago | 1

Answered
how can i save row value in variable like x(1)
>> row =[1 1 0 0; 1 1 0 0; 0 1 1 0 ; 1 1 0 0] ; x = row; x(1,:) ans = 1 1 0 0 >> x(2,:...

10 years ago | 0

| accepted

Answered
Make a function that will receive two parameters: 1. the number of multiplication tables, and 2. the number of multiplications in each table.
function multiplication_tables(x,y) [yy,xx] = ndgrid(1:y,1:x); xy = (1:y)'*(1:x); ii = [xx(:),yy(:),xy(:)...

10 years ago | 0

| accepted

Answered
How to read data from a .txt a put it in different vectors?
*EDIT* f = fopen('d20160301_2.txt'); c = textscan(f,repmat('%f',1,6),'EmptyValue',0, 'CollectOutput',1); fclose(f);

10 years ago | 0

Answered
Split a vector into multiple vectors based on a value in the original vector
V = [0 2 0 0 5 7 0 14 0 0 0 17 19 20]; V0 = V(:)'; i0 = diff(strfind([0,V0,0],0)); out = mat2cell(V0(V0 ~= 0),1,i...

10 years ago | 0

Answered
Making a matrix of NaN and integers
padarray (I, [1,1],nan); % I - your array

10 years ago | 0

Answered
I need to create an array (256 x 256) in which elements increments using loops.
I = zeros(256,256); k = 0; for i1 = 1:256 for i2 = 1:256 I(i1,i2) = k; k = k + 1; en...

10 years ago | 0

| accepted

Answered
How to read a txt that have this form?
f = fopen('d20160301.txt'); c = textscan(f,'%s','delimiter','\n'); fclose(f); k = regexp(c{:},'[A-Z]','match'); ...

10 years ago | 0

| accepted

Answered
Repetition of values in a vector.
out = sum(conv2(B,ones(4,1),'same') == 8); or a = conv2(B,ones(4,1),'valid') == 8; repeats = sum(a == 8); indexe...

10 years ago | 0

| accepted

Answered
How can I extract elements of a multi-dimensional array using the rows of another array as the indices? (more detail in the question)
A = [1,2,3;4,5,6;7,8,9] B = [1,3;2,1;3,2] C = A(sub2ind(size(A),B(:,1),B(:,2))

10 years ago | 1

| accepted

Answered
How could I convert a 3D matrix into several 2D matrix?
let A - your 3D matrice; [m,n,k] = size(A); out = mat2cell(A,m,n,ones(k,1)); out = out(:);

10 years ago | 0

Answered
How to transform a matrix in Matlab?
[m,n] = size(A); [ii,k] = ndgrid(1:n-1,1:m-1); jj = A(2:end,2:end)'; b0 = accumarray([ii(:),jj(:),k(:)],1,[n-1,n-1,m-...

10 years ago | 0

Answered
anyone help me please to crop the image into 8 bloks, 4 rows and 2 columns
[m,n,k] = size(x); out = mat2cell(x,m/4*ones(4,1),n/2*[1,1],k);

10 years ago | 0

Load more