답변 있음
How to remove the for loop?
dy = sum(triu(w(:)*ones(1,numel(w))).*toeplitz([y(1);zeros(numel(y)-1,1)],y)); dy(1) = 0;

10년 초과 전 | 1

| 수락됨

답변 있음
A=[1,3,5;9,8,7;10,15,20] use A and matrix addressing to create a 2x3 matrix consisting of the first two elements of the first column, the last two elements of the 2nd column, and the first two elements of the last row.
A = randi(125,30,3);% Let A - your data. b = A'; k = 3:6:numel(A); b([k,k+1]) = nan; out = reshape(b(~isnan(b)...

10년 초과 전 | 0

문제를 풀었습니다


Throw common elements of two vector arrays in sorted manner
Throw common elements as output in sorted manner (acending order) of two given input vector arrays

10년 초과 전

답변 있음
How to Swap alternate rows of a column matrix
n = size(A,1); k = rem(n,2); out = A(flipud(reshape(1:n-k,2,[])),:); if k == 1, out = [out;A(end,:)]; end

10년 초과 전 | 0

답변 있음
how to sum by 2 indeces?
i0 = [true;diff(A)~=0]; ii = [find(i0);numel(A)+1]; for jj = 1:numel(b) i0(ii(jj):b(jj):ii(jj+1)) = 1; end ...

10년 초과 전 | 0

| 수락됨

답변 있음
How to convert cell array to 3D array. I want to convert cell to mat
[a,b] = cellfun(@size,pu); n = numel(pu); out = zeros(max(a),max(b),n) for jj = 1:n out(1:a(jj),1:b(jj),jj) = ...

10년 초과 전 | 1

| 수락됨

답변 있음
How to rename array layer number or iteration no.
Сan it? layer1 = circshift(layer1,[0 8]); or layer1 = layer1(:,[2:end,1]); or p = [90 90 -45 0 0 45 45 0 -4...

10년 초과 전 | 1

| 수락됨

답변 있음
How to cut and add values from every iteration. Please Help
Hi Ranjan! Edited loop for..end in your code. output1 = cell(n-1,1); for jj = 2:n layer1(jj,:) = layer1(jj-1,:);...

10년 초과 전 | 1

| 수락됨

답변 있음
How to assemble the Matrix A for any number of nodes?
n = 15; a = ones(n,1); b = rem((1:n)',3)~=0; c = [1;b(1:end-1)]; d = [2*ones(6,1);ones(n-6,1)]; A = ful...

10년 초과 전 | 1

| 수락됨

답변 있음
Access subarry from large file and loop through each subarry.
A_out = accumarray(A(:,1),(1:size(A,1))',[],@(x){A(x,:)}); other: b = unique(A(:,1)); n = numel(b); A_out = cell...

10년 초과 전 | 0

| 수락됨

답변 있음
How to cut and reshape values?
layer1 = reshape(layer(2:end,:)',1,size(layer,2),5)

10년 초과 전 | 1

| 수락됨

답변 있음
How to interchange/swap variable in matrix and store it to different variable.
ii = find(idx); n = numel(ii); out = zeros(n,numel(p)); out(1,:) = p; i1 = fliplr(ii); for jj = 2:n out(...

10년 초과 전 | 1

| 수락됨

답변 있음
How can i find positions of sorted/unique values.
idx = fliplr([true, diff(fliplr(p))~=0]); out = find(idx);

10년 초과 전 | 1

| 수락됨

답변 있음
Eliminating element if a vector
a = [4 5 6 5 4 8]; ii = find(a == 6,1,'first') out = a; out(ii+1:end)=0

10년 초과 전 | 1

답변 있음
Switching individual columns in a large matrix
Let your data matrix M: a = M(:,1:4:end); b = unique(a(:)); out = zeros(numel(b),size(M,2)); for = jj = 1:size(a,2...

10년 초과 전 | 0

| 수락됨

답변 있음
how can i compare two string matrix with conditions ?
a={'yes' 'yes';'no' 'no'} b={'no' 'yes';'yes' 'no'} aby = cellfun(@(x)strcmp(x,'yes'),a) bby = cellfun(@(x)strcmp(x,...

10년 초과 전 | 1

답변 있음
Write a function so that, when given a natural number N, the function returns the value max  n ∈ N : 12 + 22 + · · · + n 2 ≤ N
your_function = @(n,m,N)sum((n+m):n:N); use >> n = 10; m = 2; N = 90; >> your_function(n,m,N) ans = ...

10년 초과 전 | 1

답변 있음
Why does my matlab function produce result more than I expect?
use: Testing;

10년 초과 전 | 0

| 수락됨

답변 있음
How to generate the random number with restrictions?
a1 = 1:28 a2 = 29:35 out = [a1(randperm(numel(a1),7)),a2(randi(numel(a2)))]

10년 초과 전 | 0

답변 있음
How to sum by 3d array?
out1 = cell2mat(accumarray(idx1,(1:numel(data))',[],... @(x){[nan(s(x(1))-1,1);conv2(data(x),ones(s(x(1...

10년 초과 전 | 0

| 수락됨

답변 있음
Incomplete time series: Fill missing dates with NaNs
k = datenum(['09-01-2013-22-49-18';'09-02-2013-07-27-48'],'mm-dd-yyyy-HH-MM-SS'); add = datestr(k(1):1/24/4:k(2),'mm-dd-yyy...

10년 초과 전 | 0

답변 있음
how can i arrange values from decimal array to the 0-255 range array?
z =[0 -0.00198139860960000 -0.00388998355544162 -0.00572886191255736 -0.00750102086941585 -0.00920933176306192 ...

10년 초과 전 | 0

답변 있음
how to truncate specific rows and columns of matrix in matlab.
out = A([1,3:end],[1,3:end])

10년 초과 전 | 1

답변 있음
How summation of two matrix so that one element of A matrix summed with B matrix and save in M(1,1)?
M = kron(ones(size(A)),B)+kron(A,ones(size(B)));

10년 초과 전 | 2

답변 있음
Extracting polynomial coefficients from function handle
reshape(str2double(regexp(func2str(f),'\d*(?=\*x\^)|(?<=\*x\^)\d*','match')),2,[])'

10년 초과 전 | 1

답변 있음
Add ddmmm to the year column
out = [arrayfun(@(x)sprintf('31May%d',x),c(:,1),'un',0),num2cell(c(:,2))];

10년 초과 전 | 0

| 수락됨

답변 있음
Fastest way to multiply each block of an array with another matrix
Let A - your array with size [12x4xN] B - matrix 4x16 sa = size(A); sb = size(B); out = zeros([sa(1),sb(2),sa(...

10년 초과 전 | 0

답변 있음
ndgrid on matrices without the use of cell arrays
m = size(A,1); % A - your array b = reshape(A,m,[],2); [ii,jj] = ndgrid(1:m); out2 = [b(jj(:),:,1),b(ii(:),:,2)]

10년 초과 전 | 1

답변 있음
How do I create a loop and put the results that satisfy the loop into a new variable?
a = fastTimes(:); ii = find(diff(a)<0.815); fastTimesChop = [a(ii),a(ii+1)];

10년 초과 전 | 0

답변 있음
detecting 6 ones in a vector
b = A == 1; % A - your array t = [true;diff(b)~=0]; n = find(t); p = [n,diff([n;numel(A)+1])]; out1 = p(A(n)==1,:)...

10년 초과 전 | 0

더 보기