문제를 풀었습니다


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

거의 14년 전

답변 있음
Question about fractional values.
use |Symbolic Math Toolbox| x = sym('5/3'); [N,D] = numden(x); out = [N,1/D];

거의 14년 전 | 0

답변 있음
extracting numbers from a string in an array
out = cellfun(@(x)str2double(regexp(x,'\d*\.\d*','match')),p);

거의 14년 전 | 2

| 수락됨

답변 있음
Compute values in the nodes of a 3d matrix
d = cumsum(BW2(:,:,end:-1:1),3); index = bsxfun(@eq,sum(BW2,3) - 1,d(:,:,end:-1:1) - cumsum(BW2,3)); T2 = T.*index + bsx...

거의 14년 전 | 1

| 수락됨

답변 있음
Error ??? Subscript indices must either be real positive integers or logicals.
use struct - array: out = cell2struct(num2cell(V),regexp(variables,'\w*','match'),2); or out = cell2struct(num2cell...

거의 14년 전 | 0

답변 있음
Given two vectors A and B, what is the best way to generate the vector C such that sum(C==A(i)) = B(i)?
A = [1 2 3]; B = [2 4 6]; i2 = cumsum(B); idx = zeros(1,i2(end)); idx(i2 - B + 1) = 1; C = A(cumsum(idx)); ...

거의 14년 전 | 1

| 수락됨

답변 있음
regexp: extra cell layer in the output
c = regexp(HeaderLine,'^(.*) Project Number:(.*) Sample Name:(.*) Depth: (.*)$', 'tokens'); out = c{:};

거의 14년 전 | 0

| 수락됨

답변 있음
How can I calculate integral?
please try this is code: sigmaZ=rand(4,4); f = @(theta)1./(arrayfun(@(x)det(sigmaZ/sin(x).^2 + eye(4)),theta)); out =...

거의 14년 전 | 0

| 수락됨

답변 있음
Compute values in the nodes of a 3d matrix
Please, try this is code: % Create the surface: x = rand(100,1)*4 - 2; y = rand(100,1)*4 - 2; S = x.*exp(-x.^2-y.^...

거의 14년 전 | 1

| 수락됨

답변 있음
I got this Error :Matrix dimensions must agree
one way %W1: n = (1:2:401).'; t = linspace(-0.5,0.5,250); f = 4/pi*sum(bsxfun(@times,1./n,sin(2*pi*n*t))); %W2:...

거의 14년 전 | 0

답변 있음
How can I convert 2-D array to 1-D array.
one way out = oprtn_pts(:); or out = oprtn_pts.'; out = out(:); other: out = reshape(oprtn_pts,[],1); ...

거의 14년 전 | 0

| 수락됨

답변 있음
finding a minimum from multiple matricies
Let your three matrices in 3D array M M = randi(234,5,5,3); % initial array [v,ii] = min(M,[],3);

거의 14년 전 | 1

답변 있음
How to store values from a loop in a matrix
M3 = cell(size(M,1),1); for ii = 1:size(M,1) X = M(ii,2); if X<60 M3{ii} = 'F...

거의 14년 전 | 1

답변 있음
How can I efficiently down-sample data that is non-uniformly spaced?
[Y, M, D, H, MN] = datevec(data(:,1)); [c,c,c] = unique([Y, M, D, H, MN],'rows'); out = accumarray(c,data(:,2),[],@mean)...

거의 14년 전 | 1

| 수락됨

답변 있음
keeping elements with specific conditions in a matrix
s = size(A); B = A(rem(s(1) - sum(A ~= 999),s(1))+1 + s(1)*(0:s(2)-1)); ADD t = A ~= 999; tt = any(t); out = ...

거의 14년 전 | 0

| 수락됨

답변 있음
Combinations of different size columns (arrays)
a = (1:5)'; b = (4:10)'; [i2,i1] = ndgrid(b,a); out0 = [i1(:),i2(:)]; out = out0(abs(diff(out0,1,2)) > eps(100),:...

거의 14년 전 | 1

| 수락됨

답변 있음
HOW TO GET TOTAL DATA FROM FOR LOOP?
try this ( *EDIT* ) dim=32; [kx,ky]=meshgrid(-1:2/(dim-1):1); circ=sqrt(kx.^2+ky.^2)<1; kx=kx/2; ky=ky/2; al...

거의 14년 전 | 0

답변 있음
delete the rows will all zeros in multi-dimensional matrix
out = reshape(M(bsxfun(@times,any(M,2),ones(1,size(M,2)))>0),[],size(M,2),size(M,3)); or only for your example reshape...

거의 14년 전 | 0

| 수락됨

답변 있음
How to calculate the median of a column depending on the value of another column?
B = accumarray(A(:,1),A(:,2),[],@median); out = [A, B(A(:,1))];

거의 14년 전 | 1

| 수락됨

문제를 풀었습니다


Create incremental spiral WITHOUT USING EVAL or FEVAL
Constructions that use feval or eval are used to cheat with cody. This test-suite tries to avoid that trick. The goal of this...

거의 14년 전

답변 있음
Change dimension of a matrix
reshape(yourmatrix,256,256,[]); or permute(reshape(yourmatrix,256,256,[]),[2 1 3]);

거의 14년 전 | 0

| 수락됨

답변 있음
High frequency large time-series matrix: Split in months
data = randi(456,800,15); % 15 samples and 800 daily data for example. datainitial = '2009-07-13'; [y,m,d] = datevec(da...

거의 14년 전 | 1

답변 있음
Converting data to decimal
hex2dec(reshape('123446739FBCDE',2,[])')

거의 14년 전 | 0

| 수락됨

답변 있음
convert image into 3XN matrix
[x,y] = ndgrid(1:size(orgim,1),1:size(orgim,2)); mydata = [y(:),x(:),orgim(:)]; or mydata = [fliplr(fullfact(size(o...

거의 14년 전 | 0

| 수락됨

답변 있음
Help with reshaping large 2D array --> 3D array -- order matters!!
A = randi(1000,84,259200); % A - initial array out = reshape(A',360,720,[]);

거의 14년 전 | 0

답변 있음
this should be easy I have a while loop that is infinite
x = 1; while x(end) < 99 x=[x x(end)+2]; end

거의 14년 전 | 0

답변 있음
How can i can convert A matrix to the type i want
I=[1 0 1 1 0 1 1 0 0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1]; I(1:size(I,1)+1:end) = 0; or I(eye(size(I))...

거의 14년 전 | 2

답변 있음
How to sort several coordinates ?
x=[3 2 1]; y=[4 5 6]; [xout,i1] = sort(x); yout = y(i1); or xy = sortrows([x;y].',1).'; yout = xy(2,:);

거의 14년 전 | 3

| 수락됨

문제를 풀었습니다


"mirror" matrix
Create n x 2n "mirror" matrix of this type: e.g. for n = 2 m = [1 2 2 1;1 2 2 1] e.g. for n = 3 m = [1 2 3 3 2 1...

거의 14년 전

답변 있음
Matlab coding to show the string in one line
out = [A{:}]; or out = cat(2,A{:}); or out = strcat(A{:});

거의 14년 전 | 0

| 수락됨

더 보기