Answered
Searching matrix for a particular value and ploting it
A = [1 2 3; 2 1 5; 6 7 5;8 2 1]; [row,col] = find(A == 1); or [row,col] = find(abs(A - 1) < eps(100)); out =...

13 years ago | 0

| accepted

Answered
How to calculate the distance between one row vector and a matrix??...
[edit] a = bsxfun(@minus,train_data,test_point); out = cellfun(@norm,num2cell(a,2));

13 years ago | 2

Answered
Dynamic Matrices in Matlab
[a,b,c] = unique(data(:,1)); d = accumarray(c,data(:,3),[],@(x){sort(x)}); n = cellfun(@numel,d); m = numel(a); out = [a, ...

13 years ago | 1

Answered
An easy Array question
DATA= [1; 2; 3; 4; NaN ; 6 ;7 ; NaN]; a = [1;4]; b = [6;7]; d = DATA(~isnan(DATA)); out = mat2cell(d(:),[diff(a)...

13 years ago | 0

Answered
Dynamic inline formula variable population
Tranfunction = 'prod(Ain,2)'; fun = inline(obj.TranFunction); NewMatrix = fun(Mat); ADD Tranfunction = '(12.*pro...

13 years ago | 0

| accepted

Answered
'How to' Matrix
other way: a - your vector - row (eg: [0 0 0 0 1]) n = numel(a); out = a(hankel(1:n,[n,1:n-1])); or out = han...

13 years ago | 0

Solved


Find max
Find the maximum value of a given vector or matrix.

13 years ago

Answered
change column in matrix
B = reshape(permute(reshape(A,size(A,1),75,[]),[1 3 2]),size(A,1),[]); or s = size(A,2); B = A(:,bsxfun(@plus,1:75:...

13 years ago | 0

Solved


Largest Twin Primes
<http://en.wikipedia.org/wiki/Twin_prime Twin primes> are primes p1, p2 = p1 + 2 such that both p1 and p2 are prime numbers. Giv...

13 years ago

Answered
How to plot a piecewise defined function?
B1=0; C1=1/2; x0 = -2:.1:2; x=abs(x0); y1=zeros(size(x)); t = [x < 1, x >= 1 & x < 2]; y1(t(:,1)) = 1/6*((12...

13 years ago | 0

Answered
How to change matrix dimensions?
M - your 3D array with size < 10000,35,12 > out = reshape(permute(M, [1 3 2]),size(M,1),[]);

13 years ago | 0

Answered
how can i store all simulation results from gibbs sampling VERTICALLY?
b = kron((1:3)',ones(3));

13 years ago | 0

Solved


Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
Given a number _n_, return the terminal value of the number chain formed by summing the square of the digits. According to the P...

13 years ago

Answered
How to convert daily data to monthly?
one way M - your data matrix with 4 columns < Year Month Day data > - double type [a,~,c] = unique(M(:,1:2),'rows'); ...

13 years ago | 3

Solved


Test if two numbers have the same digits
Given two integers _x1_ and _x2_, return |true| if the numbers written with no leading zeros contain the same digits. That is, t...

13 years ago

Solved


Television Screen Dimensions
Given a width to height ratio of a TV screen given as _w_ and _h_ as well as the diagonal length of the television _l_, return t...

13 years ago

Solved


The Dark Side of the Die
It is well-known that opposite sides of a classic hexahedral die add to 7. Given a vector of dice rolls, calculate the sum of th...

13 years ago

Answered
How can I find a correlation between two matrices
one way: out = corr( cell2mat(cellfun(@(x1)interp1(x1,linspace(1,size(x,1),size(y,1))),num2cell(x,1),'un',0)),y);

13 years ago | 0

Solved


Increment a number, given its digits
Take as input an array of digits (e.g. x = [1 2 3]) and output an array of digits that is that number "incremented" properly, (i...

13 years ago

Solved


Multiples of a Number in a Given Range
Given an integer factor _f_ and a range defined by _xlow_ and _xhigh_ inclusive, return a vector of the multiples of _f_ that fa...

13 years ago

Solved


Create a random vector of integers with given sum
Your task today is to write a function that returns a vector of integer numbers, between, and including, 1 and m, of which the s...

13 years ago

Solved


Create a random logical vector of N elements of which M are true.
Your task for tomorrow is to create a random binary (logical) vector of N elements of which M are true. For example: ran...

13 years ago

Solved


give nth decimal place of pi
max 15th place after the decimal point is ok for now

13 years ago

Solved


Reindex a vector
You are given two vectors of equal length. Vector N has numeric values (no Inf or NaN) while vector IDX has integers. Place th...

13 years ago

Solved


Rank of magic square (for beginners)
Compute the rank r of a magic square of order n WITHOUT rank and magic functions.

13 years ago

Solved


Magic is simple (for beginners)
Determine for a magic square of order n, the magic sum m. For example m=15 for a magic square of order 3.

13 years ago

Solved


Right and wrong
Given a vector of lengths [a b c], determines whether a triangle with those sides lengths is a right triangle: <http://en.wikipe...

13 years ago

Answered
how to save values in matfile as array
Elysi wrote: " ...stats = [ statmat1 statmat2 statmat3 ......... statmat24 statmat25 statmat26];..." out = reshape(stats,...

13 years ago | 0

| accepted

Answered
What can I use for equality test between input arguments of type cell?
use if strcmp(Normal{i},Patient_ID{j}) try variant of solution [num, txt] = xlsread('ExcelMainExport_ALL.xls'); ...

13 years ago | 0

| accepted

Load more