2,730 total contributions since 2018

Communication through MATLAB is always better than arguing.

Answered

How can I replace for loop with meshgrid?

You don't need a meshgrid to do the task: [ m, n ] = size( b ); d = zeros( m, n ); d( 2 : m, 2 : n ) = b( 1 : end - 1, 2 : en...

How can I replace for loop with meshgrid?

You don't need a meshgrid to do the task: [ m, n ] = size( b ); d = zeros( m, n ); d( 2 : m, 2 : n ) = b( 1 : end - 1, 2 : en...

3 hours ago | 0

Answered

Extract particular element from cell and create table with titles

T = array2table(cellfun(@(x)x(396),C),'VariableNames',{'A','B','C','D'}) % C is your cell array

Extract particular element from cell and create table with titles

T = array2table(cellfun(@(x)x(396),C),'VariableNames',{'A','B','C','D'}) % C is your cell array

5 hours ago | 0

| accepted

Answered

How can I print a fig from xy plot in Simulink.

After the simulation , type : print('MySimulinkFigure','-dpdf') % in command window

How can I print a fig from xy plot in Simulink.

After the simulation , type : print('MySimulinkFigure','-dpdf') % in command window

9 hours ago | 0

Answered

column vector with specific entries for first 4 terms

syms x % just define x as symbolic variable Coeff = sym(zeros(16,1)); Coeff(1:4) = (-(1:4).*x).'

column vector with specific entries for first 4 terms

syms x % just define x as symbolic variable Coeff = sym(zeros(16,1)); Coeff(1:4) = (-(1:4).*x).'

15 hours ago | 0

Answered

Contributors metainfo: reputation and more

Congratulations Rik for surpassing 3000 points!

Contributors metainfo: reputation and more

Congratulations Rik for surpassing 3000 points!

15 hours ago | 0

Answered

What is the best way to save data into a txt file

If your using 2019a you may try the newly introduced writematrix().

What is the best way to save data into a txt file

If your using 2019a you may try the newly introduced writematrix().

1 day ago | 0

| accepted

Answered

Couldn't find what's wrong

q = 3; b = find( cellfun( @numel, a ) == q ) %or b = find( cellfun( 'prodofsize', a ) == q )

Couldn't find what's wrong

q = 3; b = find( cellfun( @numel, a ) == q ) %or b = find( cellfun( 'prodofsize', a ) == q )

1 day ago | 1

| accepted

Answered

How to sort only nonzeros values of an array that is linked to cell array ?

[~,I] = sort(vertcat(T{:,3})); sorted_T = T(I,:); Corresponding_matche_s = T(vertcat(T{:,3})==6.008,:)

How to sort only nonzeros values of an array that is linked to cell array ?

[~,I] = sort(vertcat(T{:,3})); sorted_T = T(I,:); Corresponding_matche_s = T(vertcat(T{:,3})==6.008,:)

1 day ago | 0

| accepted

Answered

How do I put this formula int matlab?

https://in.mathworks.com/matlabcentral/answers/451685-how-do-i-put-this-formula-int-matlab#comment_684284

How do I put this formula int matlab?

https://in.mathworks.com/matlabcentral/answers/451685-how-do-i-put-this-formula-int-matlab#comment_684284

1 day ago | 1

| accepted

Answered

How to put hat over a greek symbol express its value in legend of a plot?

legend(sprintf('$\\hat{\\alpha}(0) = %d$',2),'Interpreter','latex') % ^----- numeric va...

How to put hat over a greek symbol express its value in legend of a plot?

legend(sprintf('$\\hat{\\alpha}(0) = %d$',2),'Interpreter','latex') % ^----- numeric va...

1 day ago | 0

| accepted

Answered

Transforming a multidimensional array to a two dimensional array?

reshape( yourmatrix, [ N N*n ] )

Transforming a multidimensional array to a two dimensional array?

reshape( yourmatrix, [ N N*n ] )

1 day ago | 1

Answered

Check if element in array are square of each other

nnz(V.^2==V.')>=1 % where V your vector, result 0 means false, 1 means true

Check if element in array are square of each other

nnz(V.^2==V.')>=1 % where V your vector, result 0 means false, 1 means true

1 day ago | 2

Answered

How to append elements in a vector one by one

No loop is needed: Vertically concatenate the two vectors and use reshape.

How to append elements in a vector one by one

No loop is needed: Vertically concatenate the two vectors and use reshape.

2 days ago | 0

Answered

Selecting a Range of Rows in An Array Based off a Certain Value.

a(1:find(a(:,3)==1,1,'first')-1,:) % a your matrix

Selecting a Range of Rows in An Array Based off a Certain Value.

a(1:find(a(:,3)==1,1,'first')-1,:) % a your matrix

3 days ago | 0

Answered

How can I use a loop and solve or ode45 to plot dy +4y=10 with y(0) = 0:0.1:2? Plot each solution on the same graph.

Show your attempt to get further help: y0 = 0:.1:2; % before loop ic = y(0)==y0(k) % inside loop % k loop iterator doc dso...

How can I use a loop and solve or ode45 to plot dy +4y=10 with y(0) = 0:0.1:2? Plot each solution on the same graph.

Show your attempt to get further help: y0 = 0:.1:2; % before loop ic = y(0)==y0(k) % inside loop % k loop iterator doc dso...

3 days ago | 0

Answered

How to create a matrix using conditional statements in a loop based in another matrix

H=zeros(size(Comb,1),1); idx=any(Comb,2); H(idx)=sum(Comb(idx,:),2)

How to create a matrix using conditional statements in a loop based in another matrix

H=zeros(size(Comb,1),1); idx=any(Comb,2); H(idx)=sum(Comb(idx,:),2)

3 days ago | 1

Answered

How to compare and combine two matrix

idx=A1(:,1)==A2(:,1); A3=[A1(idx,:),A2(idx,2:end)]

How to compare and combine two matrix

idx=A1(:,1)==A2(:,1); A3=[A1(idx,:),A2(idx,2:end)]

3 days ago | 0

| accepted

Answered

Matlab is not drawing my 3D function correctly with surf command

z = (c*x.^2)-(d*x.^2.*y.^2); % ^---- element - wise operation

Matlab is not drawing my 3D function correctly with surf command

z = (c*x.^2)-(d*x.^2.*y.^2); % ^---- element - wise operation

3 days ago | 0

| accepted

Answered

How to split a vector in many sub-vectors with different sizes ?

Sub=mat2cell(A,1,[3,1,2,4]); Sub{:}

How to split a vector in many sub-vectors with different sizes ?

Sub=mat2cell(A,1,[3,1,2,4]); Sub{:}

3 days ago | 0

Answered

Taking average of 3 rows from a matrix

Simpler and faster than the other two: [m,n]=size(A); % A is your matrix Mean=reshape(mean(reshape(A,3,[])),[],n)

Taking average of 3 rows from a matrix

Simpler and faster than the other two: [m,n]=size(A); % A is your matrix Mean=reshape(mean(reshape(A,3,[])),[],n)

3 days ago | 1

| accepted

Answered

Taking average of 3 rows from a matrix

Using mat2cell() and cellfun() is slower than an explicit loop follow this instead: [m,n]=size(A); % A is your matrix U1=resha...

Taking average of 3 rows from a matrix

Using mat2cell() and cellfun() is slower than an explicit loop follow this instead: [m,n]=size(A); % A is your matrix U1=resha...

3 days ago | 0

Answered

How to combine two matrix

a.'*b % a size 1 X 120 % b size 1 X 2001

How to combine two matrix

a.'*b % a size 1 X 120 % b size 1 X 2001

4 days ago | 0

| accepted

Answered

Para error at END

The loop has for missing at the beginning should be for ii = 1:21 cos() not cod().

Para error at END

The loop has for missing at the beginning should be for ii = 1:21 cos() not cod().

4 days ago | 0

Answered

Error in plot function

You have a script named plot.m please remove it from the path ,rename or delete it , it is shadowing the in-built plot() functio...

Error in plot function

You have a script named plot.m please remove it from the path ,rename or delete it , it is shadowing the in-built plot() functio...

4 days ago | 0

| accepted

Answered

Do I need pre-allocation ?

Preallocation is not necessary in your second version.

Do I need pre-allocation ?

Preallocation is not necessary in your second version.

4 days ago | 0