2.539 total contributions since 2018

Communication through MATLAB is always better than arguing.

Answered

how to find the index for the following code

“But I want to display the index of A using for loop” You don’t need one , see the documentation of fprintf(). Values=rand(1,1...

how to find the index for the following code

“But I want to display the index of A using for loop” You don’t need one , see the documentation of fprintf(). Values=rand(1,1...

etwa 3 Stunden ago | 0

Answered

How to access the specific value in table according to the input parameters?

LCA_Database(contains(LCA_Database.Name,'Construction Steel')&contains(LCA_Database.lca_phase,'D'),:)

How to access the specific value in table according to the input parameters?

LCA_Database(contains(LCA_Database.Name,'Construction Steel')&contains(LCA_Database.lca_phase,'D'),:)

etwa 4 Stunden ago | 1

| accepted

Answered

Error using horzcat with num2str function for creating character class

Str = sprintf('psd_c_%d_by_%d_shaded_%d',Nt,Bd,Ns) doc sprintf % read it

Error using horzcat with num2str function for creating character class

Str = sprintf('psd_c_%d_by_%d_shaded_%d',Nt,Bd,Ns) doc sprintf % read it

etwa 12 Stunden ago | 0

Answered

Removing elements of array by condition and without resizing?

Result=arrayfun(@(x)nonzeros(a(x,:)).',1:size(a,1),'un',0); % where a is your matrix celldisp(Result)

Removing elements of array by condition and without resizing?

Result=arrayfun(@(x)nonzeros(a(x,:)).',1:size(a,1),'un',0); % where a is your matrix celldisp(Result)

ein Tag ago | 0

Answered

Vector as Function Input

% Function Test syms a b c test1 = b+a; test2 = b^2; test3 = a^2 + c^2; test = [test1;test2;test3]; test_input = num2cell(...

Vector as Function Input

% Function Test syms a b c test1 = b+a; test2 = b^2; test3 = a^2 + c^2; test = [test1;test2;test3]; test_input = num2cell(...

ein Tag ago | 0

Answered

Parse error: The expression to the left of the equals sign is not a valid target for an assignment.

Remove curly braces. B=sort(A); Numbering variables is not recommended.

Parse error: The expression to the left of the equals sign is not a valid target for an assignment.

Remove curly braces. B=sort(A); Numbering variables is not recommended.

ein Tag ago | 0

Answered

User input in an array?

Use input() with 's' which refers to a string. https://www.mathworks.com/help/matlab/ref/input.html#btt5vtc-2

User input in an array?

Use input() with 's' which refers to a string. https://www.mathworks.com/help/matlab/ref/input.html#btt5vtc-2

2 Tage ago | 0

Answered

I have a large vector, I would like to find a set of data which is a subset of the large vector.

[lo,ii]=ismember(B,A); index = ii(lo)

I have a large vector, I would like to find a set of data which is a subset of the large vector.

[lo,ii]=ismember(B,A); index = ii(lo)

2 Tage ago | 1

Answered

How can I delete the repeated values and keep just a row of each one?

A = unique(sort(a,2),'rows') % where a is your matrix

How can I delete the repeated values and keep just a row of each one?

A = unique(sort(a,2),'rows') % where a is your matrix

2 Tage ago | 0

Answered

How to store output of a for loop in a matrix?

Idir=zeros(size(P)); % this is how you preallocate before loop Note: In this case you don’t need a loop.

How to store output of a for loop in a matrix?

Idir=zeros(size(P)); % this is how you preallocate before loop Note: In this case you don’t need a loop.

2 Tage ago | 0

| accepted

Answered

How to calculate sum of all the possible combinations of two vector elements

C=reshape((A+B.')',[],1)'

How to calculate sum of all the possible combinations of two vector elements

C=reshape((A+B.')',[],1)'

2 Tage ago | 1

Answered

sym/double error(line 665)

P.S: There is a warning at the end but yields a result without error G = matlabFunction(sqrt(1 + g_x + g_y)); % read about matl...

sym/double error(line 665)

P.S: There is a warning at the end but yields a result without error G = matlabFunction(sqrt(1 + g_x + g_y)); % read about matl...

2 Tage ago | 0

Answered

indexing an entire for loop

x = -3:0.1:3; y = -1:0.1:1; ii = length(x); jj = length(y); T = zeros(ii,jj); for k = 1:ii for l = 1:jj T(k,l...

indexing an entire for loop

x = -3:0.1:3; y = -1:0.1:1; ii = length(x); jj = length(y); T = zeros(ii,jj); for k = 1:ii for l = 1:jj T(k,l...

3 Tage ago | 0

| accepted

Answered

What is wrong with this code?

Remove the single quotes from the last line, upload the code instead of a picture. a/rw^2 == (cos(x)+(n^2*cos(2*x)+sin(x)^4))/(...

What is wrong with this code?

Remove the single quotes from the last line, upload the code instead of a picture. a/rw^2 == (cos(x)+(n^2*cos(2*x)+sin(x)^4))/(...

3 Tage ago | 1

Answered

Calculating mean over multiple dimensions

mean(data,'all') % or mean(data,[3 2 1])

Calculating mean over multiple dimensions

mean(data,'all') % or mean(data,[3 2 1])

3 Tage ago | 0

Answered

Plot multiple data in one plot using for loop

If you look the data in each cell closely infact they are all the same so all the plots overlap each other: plot(x,[y{:}]) % yo...

Plot multiple data in one plot using for loop

If you look the data in each cell closely infact they are all the same so all the plots overlap each other: plot(x,[y{:}]) % yo...

4 Tage ago | 0

| accepted

Answered

write statement without using for loop

gi=Alpha.*(bi==0)+Beta.*(bi==1)

write statement without using for loop

gi=Alpha.*(bi==0)+Beta.*(bi==1)

4 Tage ago | 1

| accepted

Answered

Need to know how to make a row vector of zeros and another number in a single command without explicitly entering the values

R=zeros(1,6); R([3 6])=6

Need to know how to make a row vector of zeros and another number in a single command without explicitly entering the values

R=zeros(1,6); R([3 6])=6

4 Tage ago | 0

Answered

For loop averaging increments

Since it’s homework take mean along the first dimension: doc mean

For loop averaging increments

Since it’s homework take mean along the first dimension: doc mean

4 Tage ago | 0

Answered

How can I subs 2 symbolic vectors in 1 comand?

Edit: Corrected the mistake. A workaround: Z=matlabFunction([X,Y]); % change this line XY=num2cell([X0,Y0]); Z(XY{:}) % eval...

How can I subs 2 symbolic vectors in 1 comand?

Edit: Corrected the mistake. A workaround: Z=matlabFunction([X,Y]); % change this line XY=num2cell([X0,Y0]); Z(XY{:}) % eval...

4 Tage ago | 0

Answered

How can I type inverse sign in axis labels? like 1/CL

xlabel('$\frac{1}{CL}$','Interpreter','latex')

How can I type inverse sign in axis labels? like 1/CL

xlabel('$\frac{1}{CL}$','Interpreter','latex')

4 Tage ago | 0

Answered

How can I get outcome at a particular value after performing differentiation?

Another option: dx(x)=diff(f); dx(3)

How can I get outcome at a particular value after performing differentiation?

Another option: dx(x)=diff(f); dx(3)

5 Tage ago | 0

Answered

How to Show 1/4 in 1/2^2?

I can only think of printing it using fprintf(): fprintf('1/%d^2 ',x)

How to Show 1/4 in 1/2^2?

I can only think of printing it using fprintf(): fprintf('1/%d^2 ',x)

5 Tage ago | 1

Answered

Find the row number of element that meets the condition

index=find(A>500,1,'first') B(index)

Find the row number of element that meets the condition

index=find(A>500,1,'first') B(index)

5 Tage ago | 1

| accepted

Answered

read csv file in sequence and post process data

Use cell arrays instead of numbering variables ( https://www.mathworks.com/matlabcentral/answers/105936-how-to-make-dynamic-vari...

read csv file in sequence and post process data

Use cell arrays instead of numbering variables ( https://www.mathworks.com/matlabcentral/answers/105936-how-to-make-dynamic-vari...

5 Tage ago | 1

| accepted