Answered
Changing Values in a while loop
I could not tell exactly what your code is supposed to do, but here I made a couple modifications: Bring the end statement that...

3 years ago | 0

Answered
I want to repeat an array by another array
A = [1,2,3,4,5]; B = [2,3,1,7,2]; % You had a mismatch in the length of B compared to A C = repelem(A,B)

3 years ago | 0

| accepted

Answered
I need to get the r-square of the model
Instead of calling the fit function with one output sf = fit([xdata, ydata], zdata, 'poly11'); call it with two outputs [sf, ...

3 years ago | 1

Answered
split mtatrix and name automatically
Anywhere that you could have used the variable name ur1, you can almost always just reference ur(:,1) directly instead, and not ...

3 years ago | 0

| accepted

Answered
Modify Tabs in Editor (Matlab 2022a)
The "Run and Time" and debugging features are now in a pull-down menu underneath the Run button in the Editor tab. I didn't fin...

3 years ago | 0

| accepted

Answered
Regression tree and prediction equation
This model is probably nonsense, because of the linear dependencies that @dpb points out. But perhaps your real data will yield ...

3 years ago | 0

| accepted

Answered
Is there a way to use a loop to generate outputs for a section of data (like rows 1 through 206) and then moving on to doing the same for subsequent rows within the same loop?
A somewhat more "advanced" way -- but perhaps more intuitive -- would be to convert Data into a 3-dimensional array first, where...

3 years ago | 0

Answered
Is there a way to use a loop to generate outputs for a section of data (like rows 1 through 206) and then moving on to doing the same for subsequent rows within the same loop?
Here is one way: for ii = 1:100 indexToThisSection = (206*(ii-1)+1) : (206*ii); Stress=Data(indexToThisSection,...

3 years ago | 0

Answered
making normally distributed over Specific Range
It is not possible to have a normal distribution in a finite range. So, we are all left guessing what the author of this docume...

3 years ago | 1

Answered
How would I go about modifying a matrix of 1's and 0's, and converting that matrix to an image (or plot)
Here is another way, plotting circles. There are probably better ways to do this. It's a bit convoluted, because of the way matr...

3 years ago | 1

| accepted

Answered
How would I go about modifying a matrix of 1's and 0's, and converting that matrix to an image (or plot)
One simple option would be to make a heatmap using imagesc: active = [0 0 0; 1 0 0; 0 0 0]; imagesc(active) axis square

3 years ago | 0

Answered
How to plot rectangles using variables
Are you trying to plot 216 rectangle with that one line? If you look at the documentation, you will see that you cannot do that....

3 years ago | 0

| accepted

Answered
Can I use google colab for running matlab codes
I don't have a definitive answer for you, but I'm pretty confident that the answer is -- No. MATLAB is definitely not made avai...

3 years ago | 1

Answered
I want to do bootstrap analysis by using 20*1 matrix.
One way is % Pretend input data M = rand(20,1); idx = randi(20,500,1); samples = M(idx);

3 years ago | 0

| accepted

Answered
I want to do bootstrap analysis by using 20*1 matrix.
If you have the Statistics and Machine Learning Toolbox, you can do % Pretend input data M = rand(20,1); samples = randsamp...

3 years ago | 0

Answered
Adding rows as a column
You really don't give enough detail about what you are trying to do. You are making us assume and/or guess too much. Maybe you ...

3 years ago | 0

Answered
How to get max of repeated values?
Here is one way; % Input C = [0.5000 0.5000 0.3000 1.0000 0.8000 0.3000 0.7000 0.7000 0.3000 0.4...

3 years ago | 0

| accepted

Answered
How to get a for to end just before Index exceeds the number of array elements?
This seems like homework, so I will give you a hint instead of just answering. It seems like according to the rules, the last e...

3 years ago | 0

| accepted

Answered
how to plot group box-lot with use of function multiple box-lot
multiple_boxplot is not built in to MATLAB. It looks like it is a user-contributed functoin that you can download from the File ...

3 years ago | 0

| accepted

Answered
Check if cell contains another cell
a{1}='1-v1'; a{2}='.*'; a{3}='3+v2'; a{4}={'this is a cell'}; cellfun(@iscell,a)

3 years ago | 0

| accepted

Answered
How to make constants global
The first google hit for searching global matlab is this documentation page on how to define global variables.

3 years ago | 0

Answered
surf plot of custom data
It looks like the data are there as you expect, and it is just a matter of zooming in to the correct part of the "landscape". He...

3 years ago | 0

Answered
How to set x axis limit while using semilogx
10^0 is 1 (not 0), so this works ... T = [0 10 100 1000 10000]; Y = [0 1 4 7 10]; semilogx(T, Y) axis([1 10000 0 12])

3 years ago | 0

Answered
Tengo esta figura, y deseo sombrear la región entre la linea amarrilla y la linea roja. Tal vez alguien pueda darme una idea de como hacerlo. Muchas gracias :)
Both the patch and fill functions are useful for doing this. See examples in the documentation.

3 years ago | 0

Answered
Create a new table with filtered rows
Here is one way. % Pretend data sports = categorical({'basketball';'volleyball';'basketball'}); num = [2;3;5]; % Put in a ...

3 years ago | 0

Answered
I get Arrays have incompatible sizes for this operation with an elseif statement what do i do?
The essence of your issue is that you are using a character array as input. When character arrays are compared with the equality...

3 years ago | 1

Answered
How to get the predicted variables name in LASSO function?
You only supplied the PredictorNames input in your call to LassoPlot, not to lasso itself. var_names_test = {'a1','a2','a3','a4...

3 years ago | 1

| accepted

Answered
Assign a line in every element of a 3d matrix
To replace all values of 10 with 101.543, you can do val(val==10) = 101.543; Maybe that helps?

3 years ago | 0

Answered
How do i use fminsearch to find the minimum or maximum of a function . x.^4-3.*x.*y+2.*y.^2
Did you try reading the documentation for fminsearch? The very first example is exactly like your problem. fun = @(x)(x(1)^4 - ...

3 years ago | 0

Answered
Why my answer is not aligned with the prompt?
You need to add a line feed. I'll use fprintf instead of input to illustrate: fprintf("1: This will split \n into two lines") ...

3 years ago | 0

Load more