Answered

Convert cell array to matrix with two columns and sort rows by first column value

I think this does what you want: % Set RNG seed, for repeatability rng default % Make up some data Cell_x = {rand(13,2),ra...

Convert cell array to matrix with two columns and sort rows by first column value

I think this does what you want: % Set RNG seed, for repeatability rng default % Make up some data Cell_x = {rand(13,2),ra...

22 Tage ago | 0

Answered

How to obtain an array of constant values from vector valued anonymous functions

f=@(x) 3.5 * ones(size(x)); v=0:10; y=f(v)

How to obtain an array of constant values from vector valued anonymous functions

f=@(x) 3.5 * ones(size(x)); v=0:10; y=f(v)

22 Tage ago | 1

| accepted

Answered

why I'm getting error " Array indices must be positive integers or logical values."

You need the multiplication sign after Patm: func_atm_pressure=@(Z) P-Patm*(1+((B*Z)/Tatm))^(g/(R*B));

why I'm getting error " Array indices must be positive integers or logical values."

You need the multiplication sign after Patm: func_atm_pressure=@(Z) P-Patm*(1+((B*Z)/Tatm))^(g/(R*B));

22 Tage ago | 0

Answered

Calculate the area between two curves

Because your curves are smooth, I think using interpolated curves will be useful: xx = 0 : 0.01 : min(max(x1),max(x2)); yy1 = ...

Calculate the area between two curves

Because your curves are smooth, I think using interpolated curves will be useful: xx = 0 : 0.01 : min(max(x1),max(x2)); yy1 = ...

22 Tage ago | 0

Answered

Create array with integral values

% original vector v = rand(1,3366); r = reshape(v,66,[]); % You may need to do a step where you remove the last row of r,...

Create array with integral values

% original vector v = rand(1,3366); r = reshape(v,66,[]); % You may need to do a step where you remove the last row of r,...

22 Tage ago | 0

| accepted

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...

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...

23 Tage 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...

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...

23 Tage 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...

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...

24 Tage 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...

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...

24 Tage 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...

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...

24 Tage 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

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

25 Tage 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...

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...

25 Tage ago | 1

Answered

For Loop that loops n times for moving average

Perhaps just use the movmean command instead?

For Loop that loops n times for moving average

Perhaps just use the movmean command instead?

25 Tage 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...

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...

25 Tage 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...

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...

25 Tage 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...

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...

25 Tage 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...

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...

25 Tage 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...

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...

26 Tage 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...

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...

26 Tage 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...

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...

27 Tage ago | 1

| 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...

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...

28 Tage 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 ...

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 ...

28 Tage ago | 0

| accepted

Answered

Delete substring within a fuction

str = '123BEMP456'; newStr = [extractBefore(str,'BEMP'),extractAfter(str,'BEMP')]

Delete substring within a fuction

str = '123BEMP456'; newStr = [extractBefore(str,'BEMP'),extractAfter(str,'BEMP')]

28 Tage 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...

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...

29 Tage ago | 2

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...

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...

etwa ein Monat 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...

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...

etwa ein Monat 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...

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...

etwa ein Monat 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...

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...

etwa ein Monat 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;

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;

etwa ein Monat 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...

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...

etwa ein Monat ago | 1

| accepted