Answered
Index exceeds the number of array elements. Index must not exceed 1
Your code gives a different error than what you are asking about, but I guess your problem comes from the expression: x(m) ins...

3 years ago | 0

Answered
I want to make an identity matrix
I've made some assumptions about the pattern, but I expect it is what you want. This should be highly efficient. The algorithm ...

3 years ago | 0

Answered
p-values of manova = 0
The p-value is going to be reported as zero if it less than either eps(0) or realmin or some other tiny number related to ho...

3 years ago | 1

| accepted

Answered
How to replace specific characters in a cell array?
With the additional description you added that clarified the problem, you can do this very easily with regexprep: A = {'MATHIEW...

3 years ago | 2

Answered
Split structured text delimated by comma in a table column
% Create the sample input table Airport = ["MUMBAI,BOM"; "NEW DELHI, DLH"; "JAIPUR,JAI"]; tbl = table(Airport); % Create te...

3 years ago | 1

Answered
How to display variables within a full sentence without using a char array or strings?
I would recommend fprintf num1 = 15; num2 = 51; fprintf("The original number was %d and the flipped number is %d",num1,num2...

3 years ago | 0

Answered
How to remove 'year' in the x-axis
The accepted answer to this question gives the following method: XDates = [datetime(2021,6,1:30) datetime(2021,7,1:31)]; YNums...

3 years ago | 1

| accepted

Answered
I have a vector where the end is padded with NaN. How to index where real numbers end and where NaNs begin
Here are two methods of finding the last index that is not NaN: load("C.mat","c") % Method 1 lastNonNanIndex1 = sum(not(isn...

3 years ago | 0

| accepted

Answered
How to replace specific characters in a cell array?
Assuming you have character array elements, and not strings, here is one way: % Inputs CC_in = {'abcdeABCDE','xyzFGHIJ'}; rep...

3 years ago | 1

Answered
Assign a set of weights to digits
% Abbreviated example input M = [4 1 1 2 0 0 0 0 0 3 1 1 2 0 0 1 0 0 1 5 1 0 0 1 0 0 0]; % If you want the weigh...

3 years ago | 0

Answered
What does the z axis mean in kmeans, pca and tsne? what data does it add that 2d doesn't? what do the axis represent?
All 2-dimensional plots in MATLAB can be rotated to be viewed from a different "point of view", but this is generally not useful...

3 years ago | 0

Answered
The problem of plotting
A quick look at the documentation for fit suggests to me that you syntax you used (to include two plots in one figure) is not va...

3 years ago | 0

Answered
bsxfun @times the row sum and @rdivide the (1./row sum) does not produce same results
In all cases, you are getting answers to within floating-point precision. For almost all purposes, you can consider these to be ...

3 years ago | 1

| accepted

Answered
Trend lines with moving average
There are many ways to do the linear fit in MATLAB, including some in base MATLAB. Here is one way, using the fitlm function fro...

3 years ago | 0

Question


Surprising behavior in randsample
I recently got surprised by the behavior of randsample. 1. Generating sequences with replacement -- not surprising When I gene...

3 years ago | 1 answer | 0

1

answer

Answered
definition of a vector
Because, according to the documentation for isvector, "A vector is a two-dimensional array that has a size of 1-by-N or N-by-1"....

3 years ago | 2

| accepted

Answered
Shapley Values for svm classification with 10 Kfold
Full disclosure: I am a bit new to this myself. I believe the reason that your code does not work is that technically, your syn...

3 years ago | 1

Answered
multiplying row vector by a scalar
% Your matrix M = magic(4) % Your scalar scalar = 100; % Multiply the third row of your matrix by your scalar M(3,:) = ...

3 years ago | 0

Answered
multiplying row vector by a scalar
You needed a colon in place of that semicolon A = data(3,:).*B

3 years ago | 0

Answered
Bessel Function Calculation in Matlab
There are a handful of mistakes in your code: In one place, you used factorial instead of the gamma function. (You need to subt...

3 years ago | 0

Answered
How to fopen in this case?
You need to concatenate two character arrays, one of which you defined ahead ... file_name='TTL_1'; fid = fopen([file_name,'.t...

3 years ago | 0

| accepted

Answered
How to eliminate a number of rows at certain points of a large data set?
Here is one way: % Pretend input data A = rand(3,100000); for ni = width(A)-999 : -1000 : 1 A(:,(ni+1):(ni+500)) = [];...

3 years ago | 1

Answered
Why this code says unrecognized function u?
I see that you have defined u in main(), but I don't see that you pass it to myGA1(). So, when myGA1() tries to pass it to Vecto...

3 years ago | 0

| accepted

Answered
Find the unique arrays in a list of arrays
% Input A = [0 1 1; 1 1 1]; B = [1 1 1; 0 0 1]; C = [0 1 1; 1 1 1]; D = [1 0; 1 1]; % Put them in...

3 years ago | 0

Answered
my output goes right to the else statement when I test it with test1=Constructt(40000,80000);
Just guessing, but maybe you intended (ShearLoad >= 20000 && ShearLoad < 45000) || (TensileLoad >= 40000 && TensileLoad < 60000...

3 years ago | 1

Answered
How could I graph the percent of variance by PC component?
You are correct that the pca function does not have an option to plot directly, and you do need to take the output and then plot...

3 years ago | 0

| accepted

Answered
Why do my matrices get separated into column intervals?
There is a very old post from MathWorks support on how to do that, here. M = magic(47); num2str(M)

3 years ago | 0

Answered
How can I put Alaska map as a background behind my contour plots?
If you have the Mapping Toolbox, you can use the usamap function to make an Alaska map, and superimpose your other data on it.

3 years ago | 0

Answered
input data while running
You can use the input command.

3 years ago | 0

Answered
Error: 'When calling a function, or indexing a variable, use parentheses. Otherwise check for mismatched delimiters.'
Is this what you are trying to do? ft = fittype( 'b + (a * ((x+k)*(x^-1)) )', 'independent', 'x', 'coefficients', {'a', 'b', 'k...

3 years ago | 1

Load more