3,129 total contributions since 2018

Communication through MATLAB is always better than arguing.

Answered

Indexing error when using the plot function.

clear all % you have a variable named plot

Indexing error when using the plot function.

clear all % you have a variable named plot

1 day ago | 2

Answered

How to make a .csv file with data values in .txt

T = readtable('data.txt'); T1 = str2double(table2cell(T)); csvwrite('Wanted.csv',T1(~all(isnan(T1),2),:)) % after this the cs...

How to make a .csv file with data values in .txt

T = readtable('data.txt'); T1 = str2double(table2cell(T)); csvwrite('Wanted.csv',T1(~all(isnan(T1),2),:)) % after this the cs...

1 day ago | 1

Answered

Cell Array with different sizes

"Ich would like to read them seperately now in variables." Terrible idea see https://in.mathworks.com/matlabcentral/answers/3...

Cell Array with different sizes

"Ich would like to read them seperately now in variables." Terrible idea see https://in.mathworks.com/matlabcentral/answers/3...

1 day ago | 0

Answered

How can I get the X and Y coordinates from an fplot graph? or from a function by parts?

h = fplot(mfinalres,[0,20]); x1 = h.XData y1 = y.YData

How can I get the X and Y coordinates from an fplot graph? or from a function by parts?

h = fplot(mfinalres,[0,20]); x1 = h.XData y1 = y.YData

1 day ago | 0

| accepted

Answered

How to assign only first member in matrix

q(t) = find(A == max1(t),1,'first')

How to assign only first member in matrix

q(t) = find(A == max1(t),1,'first')

2 days ago | 0

| accepted

Answered

How to randomly and uniquely select 2000 samples from an array with 1x460800.

val(randperm(numel(val),2000))

How to randomly and uniquely select 2000 samples from an array with 1x460800.

val(randperm(numel(val),2000))

2 days ago | 1

| accepted

Answered

ode45 or dsolve

tspan=[0 4]; y0=[0.02;0]; m=5; k=1000; c=1000; [t,y]=ode45(@(t,y)unforced1(t,y,c,m,k),tspan,y0); % function call plot(t,y(...

ode45 or dsolve

tspan=[0 4]; y0=[0.02;0]; m=5; k=1000; c=1000; [t,y]=ode45(@(t,y)unforced1(t,y,c,m,k),tspan,y0); % function call plot(t,y(...

2 days ago | 0

| accepted

Answered

for loops not working

The same goal can be achieved trivially using meshgrid() or ndgrid() without a loop: % Modes on a plate Lx=0.286; % length of...

for loops not working

The same goal can be achieved trivially using meshgrid() or ndgrid() without a loop: % Modes on a plate Lx=0.286; % length of...

2 days ago | 0

| accepted

Answered

How to extract column and row index and the corresponding value from a matrix?

m = [0 1 4 7 6 0]; [Rows,Columns] = ind2sub(size(m),(1:numel(m))'); Wanted = [Rows,Columns,m(:)]; Wa...

How to extract column and row index and the corresponding value from a matrix?

m = [0 1 4 7 6 0]; [Rows,Columns] = ind2sub(size(m),(1:numel(m))'); Wanted = [Rows,Columns,m(:)]; Wa...

2 days ago | 1

Answered

My function gives me one output instead of 2?

Call your function with two outputs.

My function gives me one output instead of 2?

Call your function with two outputs.

3 days ago | 1

| accepted

Answered

How to get line number in a text file with a specific word

No loops needed: A = regexp(fileread('fruit.txt'),'\n','split'); whichline = find(contains(A,'apple'))

How to get line number in a text file with a specific word

No loops needed: A = regexp(fileread('fruit.txt'),'\n','split'); whichline = find(contains(A,'apple'))

3 days ago | 0

| accepted

Answered

counting the number of times a number appears next to the same one in a row?

Simpler: nnz(~diff(vector)) Note: Taking into account that we only deal with integers.

counting the number of times a number appears next to the same one in a row?

Simpler: nnz(~diff(vector)) Note: Taking into account that we only deal with integers.

4 days ago | 1

Answered

How to turn an 1x1x3 array to a 1x3 vector?

reshape(array,1,[]) % or squeeze() transposed

How to turn an 1x1x3 array to a 1x3 vector?

reshape(array,1,[]) % or squeeze() transposed

4 days ago | 1

| accepted

Answered

Set values in a matrix to zero

data=[data;zeros(43,1)] % where data is of size 957 X 1

Set values in a matrix to zero

data=[data;zeros(43,1)] % where data is of size 957 X 1

5 days ago | 1

| accepted

Answered

Second Order Differential Equation

<https://in.mathworks.com/help/matlab/ordinary-differential-equations.html> - there are plenty of examples there , you were so c...

Second Order Differential Equation

<https://in.mathworks.com/help/matlab/ordinary-differential-equations.html> - there are plenty of examples there , you were so c...

5 days ago | 1

| accepted

Answered

Access matrix location on one matrix with the data location on another matrix

Probably you want: idx = setdiff(1:numel(A),B); A(idx) = 0;

Access matrix location on one matrix with the data location on another matrix

Probably you want: idx = setdiff(1:numel(A),B); A(idx) = 0;

5 days ago | 1

Answered

Using for loop to count how many times a content appears in a cell array?

T=cell2table(arr); Wanted = sortrows(varfun(@sum,T,'GroupingVariables','arr',... 'OutputFormat','table'),2,'descend') %...

Using for loop to count how many times a content appears in a cell array?

T=cell2table(arr); Wanted = sortrows(varfun(@sum,T,'GroupingVariables','arr',... 'OutputFormat','table'),2,'descend') %...

5 days ago | 1

| accepted

Answered

How to find values for corresponding start and end positons

Getting the start and positions , i believe you know it from the previous question, so don‘t waste time using a loop. bit1 =[.....

How to find values for corresponding start and end positons

Getting the start and positions , i believe you know it from the previous question, so don‘t waste time using a loop. bit1 =[.....

5 days ago | 0

Answered

How to add equation to function

Note: the following can be done trivially without a loop by vectorisation. t = 0:2:100; h=zeros(size(t)); for k=1:numel(t); ...

How to add equation to function

Note: the following can be done trivially without a loop by vectorisation. t = 0:2:100; h=zeros(size(t)); for k=1:numel(t); ...

5 days ago | 1

| accepted

Answered

Extracting values from sym matrix solutions

m.Nv11 % would give you the value , also use double() to get the result in decimal form

Extracting values from sym matrix solutions

m.Nv11 % would give you the value , also use double() to get the result in decimal form

6 days ago | 0

| accepted

Answered

Matrix Indexing with respect to sum of matrix raws

1) Sum A with respect to rows. 2) Use sort() for sum of rows and collect the second output of it. 3) Use the second output...

Matrix Indexing with respect to sum of matrix raws

1) Sum A with respect to rows. 2) Use sort() for sum of rows and collect the second output of it. 3) Use the second output...

6 days ago | 1

| accepted

Answered

Wrong output when using random numbers

./ % this is why? see Array vs. Matlab operations [Google it]

Wrong output when using random numbers

./ % this is why? see Array vs. Matlab operations [Google it]

6 days ago | 1

| accepted

Answered

Leave out dot notation in table variables

I don’t know why it’s hard for you to use "D." , see <https://in.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.ht...

Leave out dot notation in table variables

I don’t know why it’s hard for you to use "D." , see <https://in.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.ht...

7 days ago | 0

Answered

how do you get the max y value in an fplot?

h = fplot(...); MAX = max(h.YData)

how do you get the max y value in an fplot?

h = fplot(...); MAX = max(h.YData)

8 days ago | 0

Answered

How to find position of array

Simpler without any conversions: s=[1 0 1 1 0 0 0 0 1 1 1 1]; % example data x=s~=0; Start = strfind([0,x],[0 1]) End = strf...

How to find position of array

Simpler without any conversions: s=[1 0 1 1 0 0 0 0 1 1 1 1]; % example data x=s~=0; Start = strfind([0,x],[0 1]) End = strf...

9 days ago | 2