Solved


Subset Sum
Given a vector v of integers and an integer n, return the the indices of v (as a row vector in ascending order) that sum to n. I...

14 years ago

Answered
How to change interpolation results
t= 200:1500; l= pchip(l1,l2,t); plot(l1,l2,'o',t,l,'-'); axis([200 1500 0 1])

14 years ago | 0

| accepted

Solved


First non-zero element in each column
For a given matrix, calculate the index of the first non-zero element in each column. Assuming a column with all elements zero ...

14 years ago

Solved


surrounded matrix
With a given matrix A (size m x n) create a matrix B (size m+2 x n+2) so that the matrix A is surrounded by ones: A = [1 2 ...

14 years ago

Solved


Create a square matrix of multiples
Given an input, N, output a matrix N x N with each row containing multiples of the first element of each row. This also applies...

14 years ago

Solved


Vectorize the digits of an Integer
Create a vector of length N for an integer of N digits. x=123045; x_vec=[1 2 3 0 4 5]; I happened upon a trick to do ...

14 years ago

Solved


Project Euler: Problem 7, Nth prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the Nth prime nu...

14 years ago

Answered
creating dummies from a cell vector of string variables
[c c c] = unique(A)

14 years ago | 0

Solved


Sorting
Assume that x is an n-by-2 matrix. The aim is to return the first column of x, but sorted according to the second column. Exa...

14 years ago

Solved


Cell Source Index
Suppose that C is a cell array whose elements consist of row vectors of elements of the same type. For example, C could be a ce...

14 years ago

Answered
Take elements of double matrix into elements of cell
A = randi(8,3,2) B = [{2;8;9},{'as';'df';'fg'}] out = [B, num2cell(A(:,2))]

14 years ago | 0

Answered
IF statement and time display
x= {'96318.74847837' '96319.62211352' '96319.62351606' '96319.62356237' '96320.05952563' '96320.49676119'} %...

14 years ago | 0

| accepted

Answered
Vector creation with information of other vector
m1x= [550 560 562 562 645]; m1x = m1x+[false, diff(m1x) == 0]*eps(1000); pp = interp1(m1x,m1y,'linear','pp'); l1x= [5...

14 years ago | 0

| accepted

Answered
Have multiple function output in a single array
data = [ ] ; for T = T2 ; data = [data, refpropm('S','T',T+273.15,'Q',1,'R32')/1000 ] ; end or h2 = zero...

14 years ago | 0

| accepted

Answered
Converting Day of Year to month and day
% Let y - our year y = 1996; doy = 318.25; [yy mm dd HH MM] = datevec(datenum(y,1,doy)); variant of full solution ...

14 years ago | 3

| accepted

Answered
take line sum of part of matrix
A = [1, 2, 54, 4, 5, 6; ... 1, 2, 88, 4, 5, 6; ... 1, 2, 0, 4, 5, 6; ]; b = [5;2;6]; s = size(A); q = zeros...

14 years ago | 0

Answered
How to automatically add variables to a matrix with each iteration?
Strue = (pi^2)/6; Scalc = 0; n = 1; error1 = 1; while error1 > 0.001 Scalc = Scalc + (1/(n^2)); erro...

14 years ago | 0

| accepted

Solved


Pi Estimate 2
Estimate Pi as described in the following link: <http://www.people.virginia.edu/~teh1m/cody/Pi_estimation2.pdf>

14 years ago

Answered
How to generate a random number?
round(10^6*rand)*10^-5

14 years ago | 0

| accepted

Answered
Converting a vector to multiple variables required as input for 'matlabFunction'.
input = {1 1} g(input{:})

14 years ago | 9

| accepted

Answered
insert element in vector
b = 3; i1 = 3; a = [a(1:i1-1),b,a(i1:end)]; or a = [1 2 4 5]; i1 = 3; b = 3000; n = numel(b); ou...

14 years ago | 11

Answered
How to read the indivual elements of a column data?
t = str2double(x)'; year1 = fix(t/1000); day1 = t - year1*1000;

14 years ago | 1

Answered
delete element from vector
a = a(abs(a - 3) > eps(100))

14 years ago | 1

Answered
Addition of string matrices.
M ={ 'Ssu (kg COD/m³)' 'Ssu (kg COD/m³)' 'Saa (kg COD/m³)' 'Saa (kg COD/m³)' 'Sfa (kg COD/m³)' 'Sfa (kg COD/...

14 years ago | 1

| accepted

Answered
Ordering of the columns of an array according to a given line
A = [15 50 15 30 20 1 3 5 2 4]; The initial array [ii ii] = sort(A(2,:)); out =...

14 years ago | 1

Answered
i have a column matrix with zeros and ones..please give me the comment to find number of zeros in that column
A = rand(10,1) > .6; % The initial vector - column out = sum(~A); or out = nnz(~A);

14 years ago | 0

Answered
Concatenation with array of different dimensions
a = {[1;2],[4;1;9],5} m = numel(a); k = cellfun(@numel,a); out = zeros(max(k),m); for jj = 1:m out(1:k(jj),...

14 years ago | 1

Answered
Propblem with integration with constants
out = int(sym('x')) + sym('C')

14 years ago | 1

Answered
How to find last and first column of matrix which is not NaN?
|A| - your array with NaN; t = ~isnan(A); idx0 = [find(any(~t) & any(t)),find(all(t))]; idx = idx0([1,end]);

14 years ago | 0

Answered
Help with finding zero spots (fzero)
x = 0:.001:5; ff = @(x)exp(-x) - exp(-2*x) + 0.05*x - 0.25; p = ff(x); [b,b] = findpeaks(p); [c,c] = findpeaks(-p)...

14 years ago | 0

Load more