3,133 total contributions since 2018

Communication through MATLAB is always better than arguing.

Answered

Convert Cell to Matrix

As sir Walter mentioned already , you cannot have holes in matrices . So you could replace them with nans perhaps: cell_A(c...

Convert Cell to Matrix

As sir Walter mentioned already , you cannot have holes in matrices . So you could replace them with nans perhaps: cell_A(c...

약 20시간 ago | 0

Answered

Scalar Multiplication of different values at same time

Assign the values with one output for instance as variable X which consists all the values in it.

Scalar Multiplication of different values at same time

Assign the values with one output for instance as variable X which consists all the values in it.

1일 ago | 0

Answered

how to fill pre allocated matrix using two columns vectors

% Illustration Matrix = zeros(5); X = (10:10:50).'; % column vectors Y = (40:10:80).'; Matrix(end,:) = X.'; Matrix(:,1) = ...

how to fill pre allocated matrix using two columns vectors

% Illustration Matrix = zeros(5); X = (10:10:50).'; % column vectors Y = (40:10:80).'; Matrix(end,:) = X.'; Matrix(:,1) = ...

1일 ago | 0

Answered

Converting a cell type data to a 4d format

Try this: AA=cellfun(@(x) x.',A,'un',0); Wanted = cat(4,AA{:})

Converting a cell type data to a 4d format

Try this: AA=cellfun(@(x) x.',A,'un',0); Wanted = cat(4,AA{:})

1일 ago | 0

| accepted

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

2일 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...

3일 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...

3일 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

3일 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')

3일 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))

3일 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(...

3일 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...

3일 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...

4일 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.

4일 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'))

5일 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.

5일 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

6일 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

6일 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...

6일 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;

6일 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') %...

6일 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 =[.....

6일 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); ...

6일 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

7일 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...

7일 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]

8일 ago | 1

| accepted