Answered
'pca' vs 'svd' or 'eig' functions
You will get the same result from pca() if you standardize the input data first: rng default testmat = rand(20,5); % Stan...

5 years ago | 2

| accepted

Answered
Classify rows of a matrix
A=[0.9 20.1 0.3; 0.8 19 1; 0.57 20.1 0.3; 0.7 20.1 0.4; 1 19 1] [uniqueA23, ~, subs] = unique(A(:...

5 years ago | 0

| accepted

Answered
How to construct a 2 by n matrix from a given 2 by n matrix having row ratio in increasing order with MATLAB
I think this does what you want: A = [2 1 5; 4 3 6]; ratio = A(1,:)./A(2,:); [~, sorting_index] = sort(ratio); s...

5 years ago | 0

| accepted

Answered
Creating and manipulating a 7x5 matrix with zeroes , ones and eye
Here is one way to make that matrix, but see my comment about generalizability: A = zeros(7,5); A(1:2,4:5) = 1; A(3:end,1:e...

5 years ago | 0

| accepted

Answered
Unrecognized function or variable
To my knowledge, there it no MATLAB function named unit(). I also used the search bar in the documentation, and did not find an...

5 years ago | 0

Answered
If-Else Statement Error
The inputdlg returns a cell array of the string that the user enters. You need to convert that to a numeric data type. Here is o...

5 years ago | 0

Answered
How to find the index of a column data whose values are equal to another column data?
A = [31; 2; 57; 36; 87; 36]; B = [2; 36]; Ind = ismember(A,B)

5 years ago | 0

| accepted

Answered
Plotting magnitude of complex expression
The reason t ends up as a single value is that you inadvertently did a matrix division in your calculation. Try this instead: %...

5 years ago | 0

| accepted

Answered
datetime InputFormat working for one string-to-datetime conversion, failing for very similar example
FYI, you could also have done this using regular expression search: testNamestr = ... ["nsasondewnpnC1.b1.20210124.230100.c...

5 years ago | 2

Answered
replacing values in matrices under some condition
You need to also select those specific elements from win, and also create pTW of the correct size, if it does not exist. pTW = ...

5 years ago | 0

| accepted

Answered
Need Help TroubleShooting If/Else Statement
Is it possible that your input value was greater than 540? Because if it was then it will still be greater than 180 after your i...

5 years ago | 0

| accepted

Answered
Replace character in string/cell with the character above it
The general rule is not perfectly clear to me, from your small example. Do you mean that you want the even-numbered elements to ...

5 years ago | 0

| accepted

Answered
How can I plot f(x,y)= x(1-x)*y in matlab
Here is one way: x = 0 : 0.01 : 1; y = 0 : 0.1 : 10; [xx,yy] = meshgrid(x,y); f = xx.*(1-xx).*yy; figure surf(xx,yy,f)

5 years ago | 1

Answered
Not Sure How to Fix Error where I Define Function
Functions need to be defined in their own files. They cannot be specified in the command window or in scripts. Put the function...

5 years ago | 0

| accepted

Answered
define N as the number of eigenvectors needed to capture at least "99.9" of the variation in d
In general, you should provide more context and information about your question, so that we do not have to guess at what you are...

5 years ago | 0

Answered
Fit Kernel Distribution to Data with Boundary Condition
I would do this by using the ksdensity function. Specifically, see this section about using the reflection boundary condition. ...

5 years ago | 0

| accepted

Answered
how to insert inserted values in legend
I don't fully understand how you want the values to be included, but you'll probably want to use the sprintf command: alpha1 = ...

5 years ago | 1

Answered
How to sort a table based off of values in one row in MATLAB
Take a look at the documentation for the sortrows function, in particular the example on sorting rows of tables by variables. Th...

5 years ago | 0

Answered
float to binary ?
Assuming that you are using this File Exchange entry, it doesn't round. The issue is that the default MATLAB display format only...

5 years ago | 0

Answered
How to Split data into 3 equal parts (A,B,C) with balanced numbers of each subclass.
Probably the easiest way to do this would be with the following steps: Isolate each of the classes, using something like "Y == ...

5 years ago | 0

Answered
Plotting graphs with setting my own scales
figure hold on fplot (@ (x)x.^2 -2) fplot (@(x) sqrt(x+2)) fplot (@(x) (x.^2 + 2)./(2*x-1) ) fplot (@(x) (x.^2 + 2)./(2*...

5 years ago | 0

| accepted

Answered
How I plot this ?
You can use the fimplicit function. alpha1=0.1; alpha2=0.2; beta1=0.2; beta2=1; gamma=1.3; f = @(x,y) log((1+alpha1*x./(1+alph...

5 years ago | 0

Answered
How I plot this ?
Here is one way: alpha1=0.1; alpha2=0.2; beta1=0.2; beta2=1; gamma=1.3; x = 0 : 0.1 : 10; y = 0 : 0.1 : 10; [xx,yy] = me...

5 years ago | 1

| accepted

Answered
Adding 2 string row to beginning row and end row of a matrix
A numeric data type cannot hold text. You'll need to store your data in a variable that can hold mixed types. One possibility is...

5 years ago | 0

| accepted

Answered
For the following code, It shows my 51 iterations, however i only want to display the last iteration
Looks like you could just pull these lines out, and put them after the end statement of the loop: disp(['Error as percentage: '...

5 years ago | 0

Answered
Concatenate vertically multiple tables with different dimensions
You can do this with the outerjoin command: A = table([1001; 1002; 1003],{'Jones';'James';'Robert'},... 'VariableNames...

5 years ago | 0

| accepted

Answered
Standard deviation of values with standard deviation
The question you are asking is a specific instance of "propagation of uncertainty". You might want to learn more about the topic...

5 years ago | 2

| accepted

Answered
How to remove elements from two arrays when one of them has a zero
idx_to_remove = target_2019==0; target_2019(idx_to_remove) = []; output_2019(idx_to_remove) = [];

5 years ago | 1

Answered
Put specific name in file via writematrix
You need to concatenate the character arrays. Here is one way to do that: str='2020' writematrix(A,['output',str,'.xlsx'])

5 years ago | 0

| accepted

Answered
Displaying a group of vectors on separate lines
You can use a semicolon to concatenate vertically [a; b; c]

5 years ago | 0

| accepted

Load more