Answered

Am getting the error ' Array indices must be positive integers or logical values.

xander = 1/n * h1 * (sum(kiki * (([m{:}] - numel(Test)/h1)))); % ^ missed

Am getting the error ' Array indices must be positive integers or logical values.

xander = 1/n * h1 * (sum(kiki * (([m{:}] - numel(Test)/h1)))); % ^ missed

6 Tage ago | 0

| accepted

Answered

Is the following sample mean and variance fully vectorised?

MATLAB already has inbuilt functions named <https://in.mathworks.com/help/matlab/ref/mean.html *mean()*> and <https://in.mathwor...

Is the following sample mean and variance fully vectorised?

MATLAB already has inbuilt functions named <https://in.mathworks.com/help/matlab/ref/mean.html *mean()*> and <https://in.mathwor...

6 Tage ago | 0

Answered

compare two matrix one by one number to eachother

% a = > first matrix % b = > second matrix sum(a==b) % each column -> tells the number of counts of each matrix's column compa...

compare two matrix one by one number to eachother

% a = > first matrix % b = > second matrix sum(a==b) % each column -> tells the number of counts of each matrix's column compa...

6 Tage ago | 1

| accepted

Answered

How to insert a new vector to matrix in every iteration?

Trivially done without a loop: out = [repelem(x,1:numel(x));repmat(y,1,numel(x))] With loop: x=1:3; y=4:5; ctr=1; out=zer...

How to insert a new vector to matrix in every iteration?

Trivially done without a loop: out = [repelem(x,1:numel(x));repmat(y,1,numel(x))] With loop: x=1:3; y=4:5; ctr=1; out=zer...

6 Tage ago | 1

| accepted

Answered

Swap first and last word in a string

Simpler: s = 'hello world'; Wanted = swap(s) % function call % function function Wanted = swap(str) S = regexp(str,'\S*'...

Swap first and last word in a string

Simpler: s = 'hello world'; Wanted = swap(s) % function call % function function Wanted = swap(str) S = regexp(str,'\S*'...

6 Tage ago | 0

Answered

How to read multiple .txt file in MATLAB ?

Files = dir('*.txt'); n = numel(Files); MAX = zeros(n,1); for k = 1:n MAX(k) = mean(reshape(load(Files(k)....

How to read multiple .txt file in MATLAB ?

Files = dir('*.txt'); n = numel(Files); MAX = zeros(n,1); for k = 1:n MAX(k) = mean(reshape(load(Files(k)....

7 Tage ago | 0

Answered

extract column name of table with Nan column

patients.Properties.VariableNames(all(isnan(patients{:,:})))

extract column name of table with Nan column

patients.Properties.VariableNames(all(isnan(patients{:,:})))

7 Tage ago | 0

| accepted

Answered

I don't know how to plot what answer of dsolve

syms y(x) Dy = diff(y); D2y = diff(y,2); k=3; % example f = dsolve(D2y==-(exp(-k^2))*y,y(0)==1,Dy(1)==0); fplot(f);

I don't know how to plot what answer of dsolve

syms y(x) Dy = diff(y); D2y = diff(y,2); k=3; % example f = dsolve(D2y==-(exp(-k^2))*y,y(0)==1,Dy(1)==0); fplot(f);

7 Tage ago | 0

Answered

Convert Cell to variable name array

A={'sample1' 'sample2' 'sample3'} ; a = array2table(rand(3)); % an example a.Properties.VariableNames=A

Convert Cell to variable name array

A={'sample1' 'sample2' 'sample3'} ; a = array2table(rand(3)); % an example a.Properties.VariableNames=A

7 Tage ago | 0

| accepted

Answered

Ode45 iteration issue

[t1,X2]=deal(cell(numel(C1),1)); for k = 1:numel(C1) [t1{k},X2{k}] = ode45(@(t,x)fun(t,x,C1(k),C2(k),C3(k),C4(k)),t0,X01);...

Ode45 iteration issue

[t1,X2]=deal(cell(numel(C1),1)); for k = 1:numel(C1) [t1{k},X2{k}] = ode45(@(t,x)fun(t,x,C1(k),C2(k),C3(k),C4(k)),t0,X01);...

7 Tage ago | 0

| accepted

Answered

How to insert an unknown number of coloumn in a Matrix?

Try this: B=rand(3); % your initial matrix [m,n]=size(B); No_of_Columns=input('No of columns to be inserted') disp...

How to insert an unknown number of coloumn in a Matrix?

Try this: B=rand(3); % your initial matrix [m,n]=size(B); No_of_Columns=input('No of columns to be inserted') disp...

7 Tage ago | 0

| accepted

Answered

How can I set a matrix value to equal a non-numeric coordinate?

[a,b]=find(x==3)% I don't see the point of this if your assigning the same value x==3 % is already sufficient and efficient for...

How can I set a matrix value to equal a non-numeric coordinate?

[a,b]=find(x==3)% I don't see the point of this if your assigning the same value x==3 % is already sufficient and efficient for...

7 Tage ago | 0

Answered

accumulate in multiple array

splitapply(@(x) mean(x,2),Temp,findgroups(Day))

accumulate in multiple array

splitapply(@(x) mean(x,2),Temp,findgroups(Day))

7 Tage ago | 1

| accepted

Answered

Use values of array as indices for different array

D = A(sub2ind(size(A),repmat(C(:),1,size(B,2)),B))

Use values of array as indices for different array

D = A(sub2ind(size(A),repmat(C(:),1,size(B,2)),B))

8 Tage ago | 0

| accepted

Answered

Can you extract an element from an array in the same line as you create the array?

Why not? regexp(s,'\w*','match','once')

Can you extract an element from an array in the same line as you create the array?

Why not? regexp(s,'\w*','match','once')

8 Tage ago | 1

Answered

Problem when using fprintf

Look at hypot() if all(size(a) == size(b)) % change this too fprintf('Error: Input sizes are not equal\n') ...

Problem when using fprintf

Look at hypot() if all(size(a) == size(b)) % change this too fprintf('Error: Input sizes are not equal\n') ...

8 Tage ago | 0

Answered

Conditional statement of matrix

n=find(A==k) % no loop is needed if you want to know the instances of the satisfied condition

Conditional statement of matrix

n=find(A==k) % no loop is needed if you want to know the instances of the satisfied condition

8 Tage ago | 0

Answered

how to load .txt data into a function and use it as variables in matlab function

B % just call it function B % not if the file is input from outside the function then parameterize you function by prov...

how to load .txt data into a function and use it as variables in matlab function

B % just call it function B % not if the file is input from outside the function then parameterize you function by prov...

8 Tage ago | 0

| accepted

Answered

Saving all output of for loop

You don't need a loop , this is straight forward just vectorize your code: Note: The other answer doesnât show the importance o...

Saving all output of for loop

You don't need a loop , this is straight forward just vectorize your code: Note: The other answer doesnât show the importance o...

8 Tage ago | 1

Answered

Copying index positions to other matrices

B2(sub2ind(size(B),row,column))=NaN Why not directly use logical indexing from *isnan()* ?

Copying index positions to other matrices

B2(sub2ind(size(B),row,column))=NaN Why not directly use logical indexing from *isnan()* ?

8 Tage ago | 1

| accepted

Answered

deleting all rows from a table that contain a string

T(~all(strcmp(T{:,:},'empty'),2),:)

deleting all rows from a table that contain a string

T(~all(strcmp(T{:,:},'empty'),2),:)

8 Tage ago | 0

| accepted

Answered

How to classify vectors based on their value?

idx=sum(C,2)>0; A=C(idx,:) B=C(~idx,:)

How to classify vectors based on their value?

idx=sum(C,2)>0; A=C(idx,:) B=C(~idx,:)

8 Tage ago | 1

| accepted

Answered

I am not able to calculate integrals of any kind. Even the example integrals do not work.

Perhaps you would have created a custom function which don't require any output. You can check that by which integral -all An...

I am not able to calculate integrals of any kind. Even the example integrals do not work.

Perhaps you would have created a custom function which don't require any output. You can check that by which integral -all An...

8 Tage ago | 1

| accepted