Answered
How do I do this?
This seems like a homework problem, so here is a hint instead of an answer: Your problem is extremely close to the first example...

5 years ago | 0

| accepted

Answered
how to plot linear regression ?
You should plot plot(T,10.^y,'or',T,vp,'b') because you did the regression on log10(y), not y itself. vp = [ 1 5 10...

5 years ago | 0

Answered
Indexing with intercept for repeating values
Here is one way: a = [1;1;1;2;3;3;4;5;6;7]; b = [1;1;1;1;1;2;3;4;4;4;5;6;7;7]; ha = histcounts(a,1:max(a)+1); hb = histcou...

5 years ago | 0

Answered
Indexing with intercept for repeating values
Here is one way: a = [1;1;1;2;3;3;4;5;6;7]; b = [1;1;1;1;1;2;3;4;4;4;5;6;7;7]; idx = zeros(numel(b),1); ii = 1; while a...

5 years ago | 0

Answered
Matlab Function returns values
How are you calling the function? If you call it like this Hybrid(a,b,w0,s0,c,u) then it will only return the first output. Bu...

5 years ago | 0

| accepted

Answered
Random numbers and storing from 1 -5
I believe this does what you want: s = 600; x = zeros(5,s); for i=1:1:s x(:,i)=randperm(5)'; end

5 years ago | 1

| accepted

Answered
Matrix multiplication error arising
Let's ignore the scalar values a and c, which do not cause any problem. b is a 3x1 vector. d is a 10x1 vector. What do you ex...

5 years ago | 1

Answered
For Loop that loops n times for moving average
Perhaps just use the movmean command instead?

5 years ago | 1

Answered
Plot changes when using datetime
It would normally be helpful for you to upload the data so we could investigate, but in this case I think it is pretty clear. I...

5 years ago | 1

Answered
ROC Curve with 3 classes
Extending the concept of the ROC curve from a binary classification to multiclass classification is non-trivial. I had never hea...

5 years ago | 0

Answered
Difference lower then 2 in one vector
When you get to the last iteration of your loop i == length(yvars40) and therefore in your if statement, you try to compare th...

5 years ago | 0

Answered
Use for loop array value to return into for loop
I didn't look to see if this is the only problem with your code, but a problem is that your for loop has only one iteration. For...

5 years ago | 0

| accepted

Answered
Using kmedoids with custom distance function with several input variables
I think you need to do something like this. First define your MixDistance function as function D = MixDistance(X,Y) % Mixed...

5 years ago | 1

| accepted

Answered
How to save all the values of the matrix
Here is a simple adaptation of your code: M = zeros(9,3); for v = 1:9 CN = centroids(v,:); %Which Row x = CN(1); y...

5 years ago | 1

| accepted

Answered
Mesh : Display only nonzero values
In this code, I take the first example from the documenation for mesh, and don't plot the negative values by setting them to NaN...

5 years ago | 2

| accepted

Answered
sortrows descend not working
My best guess is that the first four values are not exactly the same but differ by an amount around the floating point precision...

5 years ago | 1

| accepted

Answered
Plot 2 1x4 matrices
Here is one way: x = [1 4 4 1]; y = [1 1 4 4]; figure patch(x,y,'b') set(gca,'XLim',[0 5],'YLim',[0 5]) That last line is ...

5 years ago | 0

| accepted

Answered
Delete substring within a fuction
str = '123BEMP456'; newStr = [extractBefore(str,'BEMP'),extractAfter(str,'BEMP')]

5 years ago | 0

Answered
How do I summarize this code in a for-loop?
for ne = 1:6 % Loop over the exponent q = 10^(ne-1) : (10^ne-1); p = round(q*exp(1)); %q is integer expressi...

5 years ago | 2

| accepted

Answered
Multiple one column of one matrix with all column of another matrix
If you have a relatively up-to-date version of MATLAB (R2016b or later), with implicit expansion, then output = array1(:,2).*ar...

5 years ago | 0

| accepted

Answered
take the first and last row of a matrix but sample in between
If you have the Statistics and Machine Learning Toolbox, the randsample function is handy for this: % Original data A = rand(5...

5 years ago | 0

| accepted

Answered
Handling data cell array
It's not pretty, but it does what you want: % Original data A = {'x 30%/y 20%' 'x 10%' 'x 50%/z 40%' 'z 15%' 'y 5%/z 90%' 'z 2...

5 years ago | 1

| accepted

Answered
why my kernel density function never touches x axes?
Now that we've clarified some things, let me capture my reply in an actual answer. The issue is that you have defined your X ra...

5 years ago | 0

| accepted

Answered
Replace Values Larger than Threshold with New Value, But Keep Smaller Values
If A is your matrix, then idx = A>180; A(idx) = A(idx) - 250;

5 years ago | 0

| accepted

Answered
Explanation of the following eval expression
The first, and most important, thing to mention here is that eval is almost never the best coding solution. Just as you are expe...

5 years ago | 1

| accepted

Answered
How to find product of any matrix A
Put the function definition function prod=MatProd(A) prod=1; [m,n]=size(A); for i=1:1:m for j=1:1:n ...

5 years ago | 0

| accepted

Answered
Calling python using system function
Sounds like a path issue. Type pwd in MATLAB to get your directory, and then go to that directory on the command line and try ...

5 years ago | 0

| accepted

Answered
need help in confusion matrix details
The green number in the upper-right box is the fraction of correctly classified entries in that row (and the red is the incorrec...

5 years ago | 1

| accepted

Answered
How to change my x axis value
It would be helpful if you posted your data, so we know exactly how it is stored (e.g. do you just have the years stored as nume...

5 years ago | 2

| accepted

Answered
Why variables are different tha command window values?
In the command window, you seem to be highlighting elements 1323:1325. In the variable window, you seem to be highlighting eleme...

5 years ago | 0

| accepted

Load more