Answered

n! permutation matrices

identity=eye(4); total=perms(1:4); for k=1:24 matrixperm=identity(total(k,:),:) end

n! permutation matrices

identity=eye(4); total=perms(1:4); for k=1:24 matrixperm=identity(total(k,:),:) end

1 month ago | 0

Answered

matrix of matrices - matrix with matrices inside it

use cell array: A = {[1 2 3 4] [5 6 7 8]} A{1}% get matrix 1 A{2}% get matrix 2

matrix of matrices - matrix with matrices inside it

use cell array: A = {[1 2 3 4] [5 6 7 8]} A{1}% get matrix 1 A{2}% get matrix 2

1 month ago | 0

Answered

How to compare between two cell array?

answer=cell2mat(cellfun(@(x) any(cellfun(@(y) isequal(x,y),W)),F,'uni',false))

How to compare between two cell array?

answer=cell2mat(cellfun(@(x) any(cellfun(@(y) isequal(x,y),W)),F,'uni',false))

1 month ago | 0

| accepted

Answered

Using the Mod Function to Turn a Vector (i.e. 1:15) into [1, 2, 3, 1, 2, 3, 1, 2, 3] etc.

n=3; k=[n 1:n-1]; answer=k(mod(1:15,n)+1)

Using the Mod Function to Turn a Vector (i.e. 1:15) into [1, 2, 3, 1, 2, 3, 1, 2, 3] etc.

n=3; k=[n 1:n-1]; answer=k(mod(1:15,n)+1)

1 month ago | 0

Answered

How do i determine the pixel coordinates of an image using RGB values?

image=imread('peppers.png'); R=image(:,:,1);%red chanel [x,y]=find(and(R>=230,R<=250));%here coordinates

How do i determine the pixel coordinates of an image using RGB values?

image=imread('peppers.png'); R=image(:,:,1);%red chanel [x,y]=find(and(R>=230,R<=250));%here coordinates

1 month ago | 0

Answered

Listing elements from one matrix to another

A = [0 0 0 2 1 0 0 0 0; 1 2 0 0 0 0 3 2 0; 0 0 0 2 3 1 0 0 0]; B=reshape(A',3,[])'; B(sum(B,2)==0,:)=[]

Listing elements from one matrix to another

A = [0 0 0 2 1 0 0 0 0; 1 2 0 0 0 0 3 2 0; 0 0 0 2 3 1 0 0 0]; B=reshape(A',3,[])'; B(sum(B,2)==0,:)=[]

1 month ago | 1

Answered

Find missing elements of a vector

vector =1:1:80; numbers=[ 1 3 5 12 34 44 55 62 63 68 69 70 72 75 79]; another = setdiff(vector,numbers)

Find missing elements of a vector

vector =1:1:80; numbers=[ 1 3 5 12 34 44 55 62 63 68 69 70 72 75 79]; another = setdiff(vector,numbers)

1 month ago | 1

| accepted

Answered

location of the i'th element

you can use nested loops for i = 1 : size(A,1) for j=1:size(A,2) A(i,j) end end with a loop: n = numel(A);...

location of the i'th element

you can use nested loops for i = 1 : size(A,1) for j=1:size(A,2) A(i,j) end end with a loop: n = numel(A);...

1 month ago | 0

| accepted

Answered

real time video processing

I did real-time processing with a video, what you can do is take out the frames per second of the video and with a "tic toc" to ...

real time video processing

I did real-time processing with a video, what you can do is take out the frames per second of the video and with a "tic toc" to ...

1 month ago | 0

Answered

The size of the indicated variable or array appears to be changing with each loop iteration

P=zeros(1,n+1); P(1) = P_in; for i = 2:n CR = (P_out/P_in)^(1/(i+1)); P(i) = CR*P(i-1); P(i+1) = CR*P(i); end ...

The size of the indicated variable or array appears to be changing with each loop iteration

P=zeros(1,n+1); P(1) = P_in; for i = 2:n CR = (P_out/P_in)^(1/(i+1)); P(i) = CR*P(i-1); P(i+1) = CR*P(i); end ...

1 month ago | 0

| accepted

Answered

Computation's with large numbers.

n=sym('94315998522576010519588224930693232398146802027362761139521'); answer=vpa((n-1)/2^143)

Computation's with large numbers.

n=sym('94315998522576010519588224930693232398146802027362761139521'); answer=vpa((n-1)/2^143)

2 months ago | 0

| accepted

Answered

how to randomize a vector as fast as possible

I recommend using a MEX file https://ww2.mathworks.cn/matlabcentral/fileexchange/27076-shuffle?s_tid=FX_rc3_behav if you want t...

how to randomize a vector as fast as possible

I recommend using a MEX file https://ww2.mathworks.cn/matlabcentral/fileexchange/27076-shuffle?s_tid=FX_rc3_behav if you want t...

2 months ago | 0

Answered

How i check cell in cell array is different of 0?

an example: T1={{0} {4} {5} {6} {5}} items=vertcat(T1{cellfun(@(x) ~isequal(x,{0}),T1)}); items=[items{:}];

How i check cell in cell array is different of 0?

an example: T1={{0} {4} {5} {6} {5}} items=vertcat(T1{cellfun(@(x) ~isequal(x,{0}),T1)}); items=[items{:}];

2 months ago | 0

| accepted

Answered

For Loop involving n-substitution and creating it as a row vector

n=input('the number of column for row vector= '); for i=1:n b(i)=input(['b',num2str(i),'= ']); end disp(b); y=input('i...

For Loop involving n-substitution and creating it as a row vector

n=input('the number of column for row vector= '); for i=1:n b(i)=input(['b',num2str(i),'= ']); end disp(b); y=input('i...

2 months ago | 1

| accepted

Answered

Function: Compare each Element of 2 Matrix for zero and non-zero

Z = [1,0,1;1,1,1;1,0,1] Z_2 = [2,0,2;3,1,3;2,0,2] answer=sum(sum(Z_2(Z==0)))==0;%1 if it is true

Function: Compare each Element of 2 Matrix for zero and non-zero

Z = [1,0,1;1,1,1;1,0,1] Z_2 = [2,0,2;3,1,3;2,0,2] answer=sum(sum(Z_2(Z==0)))==0;%1 if it is true

2 months ago | 0

| accepted

Answered

Indices on the left side are not compatible with the size of the right side

the problem is because you do not need to use the loop for: %begin with specifying constants AB=0.6; BC=0.1; BG=0.08; AG=A...

Indices on the left side are not compatible with the size of the right side

the problem is because you do not need to use the loop for: %begin with specifying constants AB=0.6; BC=0.1; BG=0.08; AG=A...

2 months ago | 0

Answered

I want the code to repeat for 10,000 times and add the new value to the matrix but I don't know how? Please help.

nsims = 10000; people = repmat(100,1,100); simsize = numel(people); for k = 1:nsims y = randperm(simsize, 2); ...

I want the code to repeat for 10,000 times and add the new value to the matrix but I don't know how? Please help.

nsims = 10000; people = repmat(100,1,100); simsize = numel(people); for k = 1:nsims y = randperm(simsize, 2); ...

2 months ago | 0

| accepted

Answered

How to force reshape for change elements?

m=input('z= '); n=m+1; x=zeros(n,1); for i=1:n x(i)=input(['x',num2str(i),'= ']); end x=repmat(x,1,n).^repmat((0:1:m),...

How to force reshape for change elements?

m=input('z= '); n=m+1; x=zeros(n,1); for i=1:n x(i)=input(['x',num2str(i),'= ']); end x=repmat(x,1,n).^repmat((0:1:m),...

2 months ago | 1

| accepted

Answered

'Store the first N (user enters N) Fibonacci numbers in a row vector.'I know how to get user entered number of fibbonachi numbers. But I don't know how to show them in a row vector.

clc N=input('Enter the number = '); B=zeros(1,N); B(1)=0; B(2)=1; count=1; for i=3:N B(1,i)=B(i-2)+B(i-1); end d...

'Store the first N (user enters N) Fibonacci numbers in a row vector.'I know how to get user entered number of fibbonachi numbers. But I don't know how to show them in a row vector.

clc N=input('Enter the number = '); B=zeros(1,N); B(1)=0; B(2)=1; count=1; for i=3:N B(1,i)=B(i-2)+B(i-1); end d...

2 months ago | 1

| accepted

Answered

Checking if two matrices are similar

you can check with a tolerance: tol=0.0001;%tolerance if sqrt(sum(sum((B-S*A/inv(S)).^2)))<=tol disp('It is true') else...

Checking if two matrices are similar

you can check with a tolerance: tol=0.0001;%tolerance if sqrt(sum(sum((B-S*A/inv(S)).^2)))<=tol disp('It is true') else...

2 months ago | 0

Answered

how can I create a function with multiple variables?

y=@(a,x,z) a(1) + (a(2)./z) + (a(3).*x) + (a(4).*x.^2) + ((a(5).*x)./z) + ((a(6).*x.^2)./z); x=[0.1 0.2 0.3 0.4 0.5 0.6 0.65 0...

how can I create a function with multiple variables?

y=@(a,x,z) a(1) + (a(2)./z) + (a(3).*x) + (a(4).*x.^2) + ((a(5).*x)./z) + ((a(6).*x.^2)./z); x=[0.1 0.2 0.3 0.4 0.5 0.6 0.65 0...

2 months ago | 0

Answered

How to Ignore the last line from a file read

s=readmatrix(filename); s(any(isnan(s),2),:)=[]; figure plot3(s(:,1),s(:,2),s(:,3),'*-r')

How to Ignore the last line from a file read

s=readmatrix(filename); s(any(isnan(s),2),:)=[]; figure plot3(s(:,1),s(:,2),s(:,3),'*-r')

2 months ago | 0

Answered

How can you extract odd and even rows and columns from image to seperate image outputs

B=A(2:2:size(A,1),2:2:size(A,2),:);%Even Pixels Only C=A(1:2:size(A,1),1:2:size(A,2),:);%Odd Pixels Only

How can you extract odd and even rows and columns from image to seperate image outputs

B=A(2:2:size(A,1),2:2:size(A,2),:);%Even Pixels Only C=A(1:2:size(A,1),1:2:size(A,2),:);%Odd Pixels Only

2 months ago | 0

| accepted

Answered

gpuArray for vpa (variable precision arithmetic)

In this case you are going to have to sacrifice something, if you use VPA the matrices become symbolic, therefore all the operat...

gpuArray for vpa (variable precision arithmetic)

In this case you are going to have to sacrifice something, if you use VPA the matrices become symbolic, therefore all the operat...

2 months ago | 0

| accepted

Answered

Create an RGB Image using a loop by choosing a random color for each pixel

no te sirve así? for i=1:10 imagen=uint8(randi(255,10,10,3)); figure imshow(imagen) end

Create an RGB Image using a loop by choosing a random color for each pixel

no te sirve así? for i=1:10 imagen=uint8(randi(255,10,10,3)); figure imshow(imagen) end

2 months ago | 0

Answered

inserting vectors into another new vector

A=[7 17 27 35]; B=[13 22 30 15]; N = max(numel(A),numel(B)); C=[A nan(1,N-numel(A)); B nan(1,N-numel(B))]; C(isnan(C))=[] C...

inserting vectors into another new vector

A=[7 17 27 35]; B=[13 22 30 15]; N = max(numel(A),numel(B)); C=[A nan(1,N-numel(A)); B nan(1,N-numel(B))]; C(isnan(C))=[] C...

2 months ago | 1

| accepted

Answered

How do I plot one 3D vector arrow for all points in a 3d scatter

% creating 3d scatter plot % Load data T = table((rand(100,3))); T = [table(T.Var1(:,1),'VariableNames',{'A'}),table(T.Var1(...

How do I plot one 3D vector arrow for all points in a 3d scatter

% creating 3d scatter plot % Load data T = table((rand(100,3))); T = [table(T.Var1(:,1),'VariableNames',{'A'}),table(T.Var1(...

2 months ago | 0

Answered

Represent the result of matrices manipulation as rational numbers

format rat A = [ 1/2 1/3 ; 4 5/6] B = [ 2 1/4 ; 4 1 ] C = A+B

Represent the result of matrices manipulation as rational numbers

format rat A = [ 1/2 1/3 ; 4 5/6] B = [ 2 1/4 ; 4 1 ] C = A+B

2 months ago | 0

| accepted

Answered

How would I only save variables in a list to a matlab no recursively?

n=5;%signal1 .... signal5 signallist=split(num2str(1:n,'signal%i ')); filename='here.mat'; save(filename,signallist{:})

How would I only save variables in a list to a matlab no recursively?

n=5;%signal1 .... signal5 signallist=split(num2str(1:n,'signal%i ')); filename='here.mat'; save(filename,signallist{:})

2 months ago | 0

Answered

Help with creating a different type of pareto chart?

Y=[ 81 15 21 38 38 21 31 27 22 135 55 24 54 66 97 11 117 332 140 34 456 4...

Help with creating a different type of pareto chart?

Y=[ 81 15 21 38 38 21 31 27 22 135 55 24 54 66 97 11 117 332 140 34 456 4...

2 months ago | 1

| accepted