Answered
How Can I Change the Function Interp2? I Wrote The Following Code But The Data Is Not Getting Fetched.What To Do For The Same?
You can use |griddedInterpolant|: sl = [1 1:7;2:9;3:10]; r = 0:7; theta = 0:2:4; [x,y] = ndgrid(theta,r); F...

12 years ago | 0

Answered
Vectorization of nested loops using mtimesx
for your case: ufn = bsxfun(@times,u(1:3,:,:,:),fct(end,:)');

12 years ago | 0

Answered
Indexing multidimensional matrices using logical arrays
l = r1 < .5; r1(l) = -r1(l); On comment by Marco r1 = abs(r1);

12 years ago | 0

Answered
How to insert a matrix into another matrix
A = 1:32; n = 8; s = numel(B); B = [2 2 2 ]; C = 1:numel(A)/n*(n+s)+s; rm = rem(C,n+s); l = ismember(rm,...

12 years ago | 0

Answered
how to use Arrays for plotting curves in for loop
t = (0:.1:6)'; y = sin(t*(1:3)); plot(t,y);

12 years ago | 0

Answered
reshape many submatrices to form a new matrix
From <http://home.online.no/~pjacklam/matlab/doc/mtt/doc/mtt.pdf tricks> by Peter J. Acklam: s1 = size(A); s2 = [30 30];...

12 years ago | 0

Answered
Sort values of a vector in an array according to gaps
A = [1; 2; 3; 4; 6; 7; 8; 9; 10; 12; 13; 14; 15; 16; 17; 19; 20]; B = [5; 11; 18]; i0=zeros(numel([A(:);B(:)]),1); ...

12 years ago | 0

Answered
How to calculate the average without taking zeros values?
[ii,~,v] = find(Y); out = accumarray(ii,v,[],@mean);

12 years ago | 4

| accepted

Answered
Help with cell count
r2 = {[1, 4, 3, 1]; [2, 2, 3]}; r3 = cellfun(@(x)[(1:max(x))',accumarray(x(:),1)],r2,'un',0);

12 years ago | 0

| accepted

Answered
Limiting vectors to a certain number of rows
n = 7; out = arrayfun(@(x)rand(randi(4),3),1:n,'un',0);

12 years ago | 0

Answered
Selecting only some rows of a matrix
A(all(A(:,1:2) >= -1e-3,2) & all(A <= 1e-3,2),:)

12 years ago | 0

Answered
generating a matrix question
s = [3 4];% let s - size new matrices A = hankel(2:s(1)+1,s(1)+1:sum(s)); or A = bsxfun(@plus,(1:s(1))',1:s(2)); ...

12 years ago | 0

Answered
HELP WITH ESTRACT SUBSTRING OF STRING
a = [3 -1 -1 -1 -1 -1 1 -1 -1 -1 0 -1 -1 -1 -1 4 -1 0 -1 -1 -1 0 -1 -1 3 -1 -1 -1 -1 -1 -1 4 -1 -1 0 -1 1 -1 -1 -1 0 -1 1 -1 -...

12 years ago | 0

Answered
Double integral where the limit of y is a function of x
EDIT n=1:10; t=2; a=(n-1).*t; b=n.*t; [ai,y] = ndgrid(a,b); bi = y.'; f = @(x,y,y2)logpdf(y2-x,2,1).*...

12 years ago | 0

Answered
matrix column vectors, and its elements?
circshift(A,size(A,1)/2+1)

12 years ago | 1

| accepted

Answered
simple loop option to reduce code
T = .25; n = 6; tt = -3*T/12:.001:T/12; Time1 = bsxfun(@plus,tt,diff(tt([1,end]))*(0:n-1)');

12 years ago | 0

Answered
periodic function with n cycles
t = 0:pi/100:6*pi; t1 = rem(t,2*pi/3); l = t1 < pi/3 ; F = @(t,l)sqrt(3)*l + sin((2*pi*l + ~l).*t -2*pi/3*l); out...

12 years ago | 1

| accepted

Answered
Using ngrid to create a matrix listing all combinations of values from row vectors
A= [1 2 3 4]; B= [1 2]; C= [1 2 3 6 7 8]; D= [1 3 6]; CC = {A,B,C,D}; n = cellfun(@numel,CC); n1 = cumsu...

12 years ago | 1

| accepted

Answered
How to compare a vector A of real numbers with a vector of zeros using equalities and inequalities?
C = [A(1:n) == 0;A(n+1:end) <= 0];

12 years ago | 0

| accepted

Answered
Can anyone replace FOR loop with WHILE loop?
k = 0; x = 0; while x >= 0 k = k + 1; x = 50 - k^2; end y = sqrt(x);

12 years ago | 0

Answered
Simple interpolation inside matrix
A =[ 1 1 1 1 1 1 1 60 1 1 1 1 1 1 1]; bw = A>1; B = b...

12 years ago | 0

| accepted

Answered
Compare two cell arrays of different sizes
[l,ii] = ismember(final_gps(:,1),final_iono(:,1)); C = cat(1,final_gps{l,2}).^3./cat(1,final_iono{ii(l),2}); ADD l ...

12 years ago | 0

| accepted

Answered
Find the maximum number and its location in the matrix
[val,idx] = max(K(:)); [ir,ic] = ind2sub(size(K),idx);

12 years ago | 1

Answered
I have 6 hourly data set , with 4 entries for a day, 6,12,18,24. I want a daily data set with a single data for a day, Time series is given below
d = data(:,4:end); % Here data - your array [ii,jj] = ndgrid(data(:,2),1:size(d,2)); out = [2005*ones(data(end,2),1),......

12 years ago | 0

Answered
how to change part of a matrix into zero
n = round(numel(A)*.1); B = A'; B(1:n) = 0; B = B';

12 years ago | 3

Answered
How to generate random time series with specified max-min time intervals?
One way d = .5 + 1.5*rand(70,1); d2 = [0;cumsum(d)]; out = [d2(d2 < 60 - .5);60];

12 years ago | 0

Answered
Identifying sequences of two or more and maintaining vector shape
x = [0 112 58 0 0 0 0 114 0 24 0 0]; x(strfind([0,x(:)' ~= 0, 0],[0 1 0])) = 0;

12 years ago | 0

| accepted

Answered
Rename multiple files by substituting specific characters
files = dir('*.csv'); [~,ii] = sort(cellfun(@(x)sscanf(x,'file.%d.csv'),{files.name})); file_sorted = files(ii);

12 years ago | 0

| accepted

Answered
Irregular time series data interpolation
f = fopen('yourdata.txt'); c = textscan(f,'%s %s %f'); fclose(f); DT = datenum(strcat(c{1:2}),'mm/dd/yyyyHH:MM');...

12 years ago | 0

| accepted

Answered
How can i optimize a symbolic function?
Please try this is code: z = ... subs(5.3*p(1) + 5.5*p(2) + 5.8*p(3) +... 0.004*p(1)^2 + 0.006*p(2)^2 + 0.009*p(3)^2...

12 years ago | 0

Load more