Answered
Sawtooth wave, using complex fourier transform find first 7 harmonic
N = 512; u = linspace(0,1,N+1); U = fft(u(1:end-1))'/N; U_0_7 = U(1:8); U_0_7(2:end) = U_0_7(2:end)*2; U_0_7 = ...

9 years ago | 1

| accepted

Answered
Working with phone number data. Number to String
One way c = xlsread('A.xlsx'); out = sprintfc('%d',c);

9 years ago | 0

Answered
how to find the odd numbers i need?
N = 12; out = 1:2:2*N

9 years ago | 1

| accepted

Answered
read data from file to two-dimensional array
fileI = fopen('file.txt','r'); Vx = fscanf(fileI,'%f'); fclose(fileI); out = reshape(Vx,50,[]);

9 years ago | 1

| accepted

Answered
Test for within cell array boundaries
inbounds = @(myarray,indexes)all(size(myarray) >= indexes(:)'); use: >> inbounds = @(myarray,indexes)all(size(myarray)...

9 years ago | 0

| accepted

Answered
How to find max value and reduce it from other arrays
g = findgroups(M(:,1)); ia = accumarray(g,1); out = M; out(:,5) = out(:,3) - out(:,4)./ia(g); t = M(:,4) < 0; o...

9 years ago | 0

Answered
I want to store the output from my nested for loop in a matrix . How can it be done?
*[EDIT]* Bw=[150 155]; Rbwtobtf=[0.2,0.21]; Hf=[70 75]; Rdtoh=[0.85 0.86]; Tbf=[115 120]; Bbf= [250 260]; ...

9 years ago | 1

Answered
How to solve : Subscripted assignment dimension mismatch error
Use cell - array ( |Aout|) for output data in your function A=randi(10,2,3); Aout = cell(size(A); for i=1:2 ...

9 years ago | 0

Answered
Insert Value into Matrix.
out = [0;Velosity(:)];

9 years ago | 0

| accepted

Answered
Embedding an array into another: vectorization method
seq1 = (1:10); seq2 = {2,'p';5,'q';7,'r';10,'s';33,'t'}; n = [seq2{:,1}]'; s = seq1(:); i0 = (min(min(s),min(n...

9 years ago | 1

| accepted

Answered
i have N observations z(1),z(2),...z(N) how can do the following formula , where N=50
*[EDIT]* MATLAB >= R2016b N = numel(Z); a = triu(toeplitz(Z)); a = [a,a(:,end-1:-1:1)]./exp((1-N:N-1)*20); K = ...

9 years ago | 0

| accepted

Answered
How to sort a matrix in matlab
A = [1 50 0 10 2 0 0 0 3 0 30 0 4 0 15 0 5 45 0 65 6 55 0 0 7 0 10 0 8 0 0 90 9 0 0 5 10 10 0 0 ...

9 years ago | 0

Answered
How to build a new matrix based on some available information
E = [ 1 260 120 1 340 60 1 455 300 1 555 60 2 620 120 2 705 60 2 720 360 2 1025 60 2 1045 60 3 1...

9 years ago | 0

Answered
How to manipulate in matrix
[~,~,c] = unique(ii(:,1)); D = accumarray(c,ii(:,2)); out = [ii(:,1), D(c)];

9 years ago | 0

Answered
max_product that t takes v as vector and n as positive integer
max_product = @(A,n)max(exp(conv2(log(A(:)),ones(n,1),'valid'))); use: >> [value,ii] = max_product([1 2 3 4 5 6 7 8 9 ...

9 years ago | 1

Answered
Comparing two Matrix for similar elements
c = nnz(A(:)' == B(:)); % MATLAB >= R2016b c = nnz(bsxfun(@eq, A(:)', B(:))); % MATLAB <= R2016a

9 years ago | 0

Answered
how to split an array with a periodic set of elements as it reaches to the maximum elements?
B = mat2cell(A(:)',1,diff(find([true,diff([A(:)'== 5,0]) == -1])));

9 years ago | 2

| accepted

Answered
How to count and reduce values in matrix
a = input; ii = accumarray(a(:,1),1); out1 = [a(:,1:2),a(:,3) - a(:,end)./ii(a(:,1))]; t = ismember(a(:,2),3:...

9 years ago | 0

| accepted

Answered
How to replace the diagonal elements of a matrix with 0 fro avoiding self loops?
out = M - diag(diag(M));

9 years ago | 19

| accepted

Answered
Trying to go from 1 matrix to a structure with a condition in the next column
t = real_TTC >= 1.5; s = {'critical';'non_critical'}; T = table(real_TTC,s(t + 1),'VariableNames',{'A' 'critical'});

9 years ago | 1

Answered
Hi, I have a cub matrix [x,y,z] which x=2725, y=2040, and z=102. I want to mutiply each pixel (i,j,1:102) by a 2D matrix [ 78 102] using arrayfun function. Final results is [2725 2040 78].
A = IhyperCube; B = VF; CHC = squeeze(sum(A.*permute(B,[4,3,2,1]),3)); % MATLAB >= R2016b CHC = squeeze(sum(bsxfun(...

9 years ago | 0

Answered
I have to find multiple series of numbers in a single matrix.
ii = [1 2 3 4 5 6 8 9 10 11]; C = mat2cell(ii,1,diff([0,find(diff(ii) > 1),numel(ii)]));

9 years ago | 1

Answered
How to separate symbolic equation coefficients
syms A B x y L = A*x + B*y; out = coeffs(L,[x,y])

9 years ago | 0

Answered
multiplying matrices with an array in order to create a rotation matrix
Ky = matrixKy^2; h = reshape(hoeky,1,1,[]); matrixRy = (1-cos(h)).*Ky + sin(h).*matrixKy + matrixI; % MATLAB >= R2016b ...

9 years ago | 0

Answered
how do I turn the columns and rows in a random matrix?
rot90(your_matrix,2)

9 years ago | 0

Answered
How can I define elements as belonging to different clusters in a matrix?
Please use function <http://se.mathworks.com/help/images/ref/bwlabel.html?searchHighlight=bwlabel&s_tid=doc_srchtitle |bwlabel|>...

9 years ago | 0

Answered
find a mean of values in a field of a struct
for ii = 1:numel(userTouristicTraj) if ~isempty(userTouristicTraj(ii).pauseTime) userTouristicTraj(ii).pause...

9 years ago | 0

| accepted

Answered
how to multiple elements in arrays together
dT = 45; hh = [8;20]; I = input ('heat transfer coefficient of 8 or 20?\n'); h = hh(ceil(I/9)); k = 204; d = 0....

9 years ago | 2

Answered
2D Random path within a unit square
n=1000; mypath = rand(n,2); m = cumsum(mypath); mout = m./m(end,:); % MATLAB >= R2016b mout = bsxf...

9 years ago | 0

Answered
remove duplicated rows from a cell array ?
cell1 = {'ESF','BRCA1';'ELANE','SLPI';'NBR1','TTN';'SLPI','ELANE'}; [~,~,c] = unique(cell1); [~,~,c1] = unique(sort(r...

9 years ago | 0

Load more