Answered
Using find in a loop
I = [1, 2, 4, 3,3,3,5, 10,8,7, 2,4, 5, 6, 8,6,5 ]; for ii = 15:-1:1 [Maxi(ii,1),jj]= max(I(ii:(ii+2))); I_Max...

13 years ago | 0

Answered
how to random -1 and 1?
2*randi([0 1],8)-1 or 2*(rand(8)>.5) - 1

13 years ago | 4

Answered
How to find specifying pattern in the string
out0 = regexp(s,'^V(b|x)x_\w*','match'); out = cat(1,out0{:});

13 years ago | 1

Answered
Add a certain row to each new row generated by same loop function ! HOW!
input1 = randi([10 100],10,1); % Let your data input2 = randi(9,10,1); [j1 j2] = ndgrid(input1,input2); [a ,b...

13 years ago | 0

| accepted

Answered
how to make it short codes?
Use <http://home.online.no/~pjacklam/matlab/doc/mtt/doc/mtt.pdf tricks> by Peter Acklam B = randi(300,128,128); % Let you...

13 years ago | 1

| accepted

Answered
How to remove outliers from 2D array
l1 = a <= 1 & a >= 0; n = sum(l1,2)./n; mn = sum(a.*l1,2)./n; sd = sqrt(sum((bsxfun(@minus,a,mn).*l1).^2,2)./n); O...

13 years ago | 0

Answered
Assigning a variable to equal another in a for loop
Ele = bsxfun(@plus,(0:10:20)',1:10); EleColumn = permute(reshape(Ele,size(Ele,1),2,[]),[1 3 2]);

13 years ago | 0

Answered
Extracting text from a cell
B = regexp(A,'^.{0,6}','match') B = cat(1,B{:});

13 years ago | 0

Answered
help with applications in numerical analysis
the code will work. other variant: q=0:0.05:4; s = arrayfun(@(z)quad(@(z)sin(z^2),0,z),q); c = arrayfun(@(z)quad(@...

13 years ago | 0

Answered
help with numerical analysis
syms R H V real H = 3*V/(pi*R^2); S = subs(pi*R*sqrt( R^2/4+H^2 ),V,250); Rout = double(solve(diff(S,R),R)); Rou...

13 years ago | 0

| accepted

Answered
how to find mean for the values in an image
for youe case without blockproc (without Image Processing Toolbox): kron(cellfun(@mean2,mat2cell(x,2*[1 1],2*[1 1])),[1 1; ...

13 years ago | 0

Answered
Combining matrices of different sizes
x = [1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]; y = [1 2 3;4 5 6;7 8 9]; [i1,j1] = ndgrid(1:size(x,1),1:size(x,2)); ...

13 years ago | 19

| accepted

Answered
white space in cell array
string = 'I am 24 Years old'; strrep(string,' ',''); for cell array string = {'I am 24 Years old';'I am 24 ...

13 years ago | 3

| accepted

Answered
Array - Determine parameters (least number picked etc)
Use functions: 1. <http://www.mathworks.com/help/matlab/ref/min.html |min|>; 2. <http://www.mathworks.com/help/matlab/ref/...

13 years ago | 0

Answered
How to delete rows from a matrix array ?
t = ~cellfun('isempty',waterConductivityData); d = waterConductivityData{3}; ii = cellfun(@(x)numel(x)> 8,regexp(d,'\d'...

13 years ago | 0

Answered
How can I interpolate a pressure vector to the surface?
lon = randi([-180,180],32,1); lat = randi([20,50],32,1); P = randi([10,1000],32,1); % your data F = scatteredI...

13 years ago | 1

Answered
How to make my code runs faster?
x=-3:0.01:3; ST = 2*quadv(@(s) sin(s).*cos(s*x)./s,0,12)/pi; or x=-3:0.01:3; ST = integral(@(s) sin(s).*cos(s*x)...

13 years ago | 0

| accepted

Answered
how can I transform the n monomial of a polynomial into n variables?
syms a b c y = 3*a+4*b+5*c; out = fliplr(coeffs(y)).*symvar(y)

13 years ago | 0

| accepted

Answered
datenum input string format
q = '2012-06-01T03:15:00Z' out = datenum(str2double(regexp(q,'\d*','match')));

13 years ago | 0

Answered
how to rearrange the code in simple way
ii = reshape(q(1:10,1:419)',[],1)'; % your 'input'

13 years ago | 0

Answered
Store data in cell arrays
a =[26.81267 1 26.82500 1 26.83733 1 26.86200 1 37.41933 0 37.40700 0 37.39466 0 37.38233 0 27.08400 1...

13 years ago | 0

Answered
how to combine a set of data into one cell
num2cell(A,2)

13 years ago | 0

Answered
finding location of numbers in matrix
A=[2 3 4; 3 2 2 ;5 6 7] [ii,jj]=find(A'>2) out = accumarray(jj,ii,[],@(x){x'})

13 years ago | 3

Answered
How can I add new data to specific row and colum of a matrix
A = [1 2 5; 3 4 6; 7 8 9] B = zeros(size(A) + 1) B([1 1 0 1]>0,[1 0 1 1]>0) = A OR A = reshape(1:9,3,[])'; B ...

13 years ago | 0

Answered
efficient way of transforming vector
A =[2 1 0 3]; n = A ~= 0; k = cumsum(A); k1 = k(n); s = (1:numel(A))'; s1 = s(n); ...

13 years ago | 1

| accepted

Answered
how to calculate distance of points
P - your data containing values of (xi,yi). < 150 x 2 double > P = randi(250,150,2); % eg out = pdist(P); in tab...

13 years ago | 1

| accepted

Solved


Fahrenheit to Celsius using multiple statements
Given a Fahrenheit value F, convert to a Celsius value C. While the equation is C = 5/9 * (F - 32), as an exercise use two state...

13 years ago

Solved


Average of square wave
given positive and negative peak , calculate dc level, 50% duty cycle

13 years ago

Solved


Multielement indexing of a row array
The row array birthRateChina stores the China birth rate (per 1000 people) for years 2000 to 2012. Write a statement that create...

13 years ago

Solved


Generate the Matrix!
Given n, generate the following matrix: a = [ n n-1 n-2 ... 2 1; n-1 n-1 n-2 ... 2 1; n-2 n-2 n-2 ... 2 1;...

13 years ago

Load more