Answered
extract the information from a matrix with three columns
*_EDIT_* load('y.mat'); [yy,i0] = unique([y(:,1:2);y(:,[2 1])],'rows'); y3 = repmat(y(:,3),2,1); y3 = y3(i0); [...

9 years ago | 0

| accepted

Answered
Can I have a code that detects # of element transitions and return a matrix that has only rows of minimum element transitions?
_...row 2, 3 , 4 are compared to 1 then row 3, 4 compared to 2 and so on..._ C = squeeze(sum(bsxfun(@minus,A,permute(A,...

9 years ago | 0

Answered
nearest value but bigger nearest
k = bsxfun(@minus,A(:)',B(:)); k(k >= 0) = -inf; [~,ii] = max(k); ii(all(k == -inf)) = 0;

9 years ago | 0

| accepted

Answered
Find the indices of elements of matrix that were multiplied
A =[ 8 1 6 3 5 7 4 9 2]; n = 2; s = size(A); B = real(exp(conv2(log...

9 years ago | 1

Answered
Sum of nonzero vector elements
v= [1 2 3 0 0 0 4 5 0 6 7 0 8 9]; b = bwlabel(v(:)); [a,ii] = unique(b,'first'); indx = ii(a ~= 0); t = b ~= 0...

9 years ago | 1

Answered
converting string to double
'1234' - '0'

9 years ago | 2

Answered
problem with sorting a structure
images=dir('file*.tif'); n = {images.name}'; [~,ii] = sort(str2double(regexp(n,'(?<=file)\d*(?=\.txt)','match','once')))...

9 years ago | 1

| accepted

Answered
Matrix A & B need to be merged, Can I delete a complete raw if one appears in both matrices and same column position?
Hi friends! Please my small contribution: jj = reshape(permute(... bsxfun(@plus,permute(A,[3,2,1]),B),.....

9 years ago | 1

Answered
how to use for loops command to ignore 10 times the same code?
[NUMERIC,TXT]=xlsread('whole10L22.xlsx'); x= NUMERIC(:,1); y = NUMERIC(:,2); Mag = NUMERIC(:,3); date_num = datenu...

9 years ago | 2

| accepted

Answered
3D matrix time 2D matrix
Let your |gamma| -> |gamma1| (because |gamma| - name of the function from MATLAB) s = size(relu); M = s(1) * s(2); N ...

9 years ago | 2

| accepted

Answered
How to rewrite a conditional recursive funtion without for-loop
Hi Pascal! Please only with |for-end| loop: nn = [n1,n2,n3]; % nn = randi([0 10],20,3); t = all(nn > 0,2); nn(:,3)...

9 years ago | 0

Answered
How to add data in a matrice?
without loop: F = reshape(1:32,4,[])';

9 years ago | 0

| accepted

Answered
summing logicals i times where i is taken from a matrix of integers
*_EDIT_* crit = 0.395; z = max(R(:)); n0 = numel(R); s = size(R); Lo = crit >= rand([s,z]); ii = reshape...

9 years ago | 1

| accepted

Answered
find a value and following values in a matrix
out = (cumsum(A == 23,2)>0).*A

9 years ago | 1

| accepted

Answered
Definite Integrals in for-loop
Please try code below J = linspace(0,1,1000); kappam = 2*(tanh(2*J)).^2-1; f = @(phi)sqrt(1- kappam.^2 * sin(phi...

9 years ago | 1

| accepted

Answered
How to rewrite recursive funtion without for-loop
a = 1:20; b = 5; c = 3; a1 = a; a1(1:2) = 0; x = filter(1,[1,-b,-c],a1(:));

9 years ago | 2

| accepted

Answered
How to convert arrayfun to for loop
Array = hankel(1:27,[27,1:26]); or count = 27; L = (1:count)'; Array1 = zeros(count); for jj = 1:count ...

9 years ago | 0

Answered
How to take hourly average from 15 minutes random data.
d = xlsread('data1.xlsx',1,'A2:B1147'); d0 = datevec(d(:,1) + datenum([1900 1 -1])); [a,b,c] = unique(d0(:,1:4),'rows','...

9 years ago | 1

Answered
Matlab: trasform cell arrays into a matrix
zz = cat(1,U{:}); zz(cellfun(@isempty,zz)) = {0}; Z = cellfun(@(x)x(1),zz);

9 years ago | 1

| accepted

Answered
Find Indexes above zero in a matrix and replace thoses indexes with the value of a vector with the same length.
B = bsxfun(@times,A > 0,V) + A.*(A <= 0); or [ii,jj] = find(A > 0); B = A; B(sub2ind(size(A),ii,jj)) = V(ii);

9 years ago | 0

| accepted

Answered
How to convert a 3d matrix to a matrix of cells?
C = cellfun(@(x)reshape(x,[],1),num2cell(M,3),'un',0);

9 years ago | 1

| accepted

Solved


Determine if a Given Number is a Triangle Number
*Description:* Determine if the elements of an input array are triangle numbers and return the result as an array with the sa...

9 years ago

Solved


Isothermal Expansion
Given the initial pressure and volume of an ideal gas, calculate the new volume, given the new pressure. Hint: <https://en.wi...

9 years ago

Solved


Remove the vowels
Remove all the vowels in the given phrase. Example: Input s1 = 'Jack and Jill went up the hill' Output s2 is 'Jck nd Jll wn...

9 years ago

Solved


Calculating cost
You sold a Product at $x and gain 10% What was the cost of the product?

9 years ago

Solved


Create times-tables
At one time or another, we all had to memorize boring times tables. 5 times 5 is 25. 5 times 6 is 30. 12 times 12 is way more th...

9 years ago

Answered
How to create a matrix with for-loop when the columns are unknown?
Let |y_point| - vector [n x 1] [ii,jj] = find(abs(bsxfun(@minus,y_function(:),y_point(:)')) < 1e-3);

9 years ago | 2

| accepted

Answered
Hi everyone, can you help me to solve following program
A = [1,2,3;4,5,6;7,8,9]; C = toeplitz([ones(1,3),2*ones(1,2)],[1 2 2]); C(C==1) = A;

9 years ago | 1

Answered
How to create a piecewise function with if and else statements?
t = -5:30; t0 = [-inf 0 8 16 26 inf]; [~,ii] = histc(t(:),t0); f = {@(t)zeros(size(t)); @(t)10.*t.^2 - 5....

9 years ago | 0

Answered
Matlab to extract the n th diagonals in a Matrix
A = randi(9,5); n = [2,4]; A(sub2ind(size(A),n,n)) = 100*n;

9 years ago | 0

Load more