3,718 total contributions since 2014

Suspensa Vix Via Fit

Answered

Too many files open error yet I am closing files

_"...you will see that after I complete reading each file I close the file using fclose(fID)."_ Nope. You actually only close...

Too many files open error yet I am closing files

_"...you will see that after I complete reading each file I close the file using fclose(fID)."_ Nope. You actually only close...

10 hours ago | 0

| accepted

Answered

What is the difference between mean(A,'omitnan') and nanmean(A) ?

There is no practical difference for your vector. Personally I would use |mean|, because |nanmean| is part of the Statistics ...

What is the difference between mean(A,'omitnan') and nanmean(A) ?

There is no practical difference for your vector. Personally I would use |mean|, because |nanmean| is part of the Statistics ...

10 hours ago | 1

| accepted

Answered

There's an error using input function in my computer , how do I solve it?

The error message is telling you that you have a file named |input|: have a look at the second line of the error message: what d...

There's an error using input function in my computer , how do I solve it?

The error message is telling you that you have a file named |input|: have a look at the second line of the error message: what d...

12 hours ago | 0

Answered

How can I retrieve an element from this array of functions, as a matlabFunction?

Use a cell array to store function handles: C{1} = @(t,y) 10*(y(2)-y(1)); C{2} = @(t,y) y(1)*(28-y(1))-y(2); C{3} = @(t,...

How can I retrieve an element from this array of functions, as a matlabFunction?

Use a cell array to store function handles: C{1} = @(t,y) 10*(y(2)-y(1)); C{2} = @(t,y) y(1)*(28-y(1))-y(2); C{3} = @(t,...

14 hours ago | 1

| accepted

Answered

parfor is slower than for

_"I don't see a reason why parfor should be slower than for."_ I don't see a reason why |parfor| should be faster than |for|....

parfor is slower than for

_"I don't see a reason why parfor should be slower than for."_ I don't see a reason why |parfor| should be faster than |for|....

17 hours ago | 0

| accepted

Answered

Executing eval in function handle ?

This is a classic example of how the decision to use |eval| to access variables just makes code more complex and introduces more...

Executing eval in function handle ?

This is a classic example of how the decision to use |eval| to access variables just makes code more complex and introduces more...

17 hours ago | 2

| accepted

Answered

I have a cell array of size 1x934 and each cell has 160x160x96 double. I want to make a cell array of 1xn (n i think it is 89664) where each cell has 160x160

*Method one: concatenate into one numeric array, then split.* This will not work of you do not have enough memory for the comple...

I have a cell array of size 1x934 and each cell has 160x160x96 double. I want to make a cell array of 1xn (n i think it is 89664) where each cell has 160x160

*Method one: concatenate into one numeric array, then split.* This will not work of you do not have enough memory for the comple...

19 hours ago | 0

Answered

Create a loop with string

Using _command syntax_ with <https://www.mathworks.com/help/matlab/ref/load.html |load|> is one of the main bugs in the code: as...

Create a loop with string

Using _command syntax_ with <https://www.mathworks.com/help/matlab/ref/load.html |load|> is one of the main bugs in the code: as...

22 hours ago | 0

Submitted

ColorBrewer: Attractive and Distinctive Colormaps

The complete palette of ColorBrewer colormaps. Simple selection by scheme name and map length.

23 hours ago | 302 downloads |

Answered

How to display averages in new array?

This is easy in just a few lines. B = [... 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000...

How to display averages in new array?

This is easy in just a few lines. B = [... 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000...

1 day ago | 0

Answered

How do I format a .txt file I've created?

%15:9e is not a valid format string. Perhaps you meant to write a decimal point: %15.9e

How do I format a .txt file I've created?

%15:9e is not a valid format string. Perhaps you meant to write a decimal point: %15.9e

2 days ago | 0

| accepted

Answered

Trying to do repeat math on multiple variables...

David Fletcher already showed the best way of doing this, which is to use MATLAB efficiently with one numeric array. If you real...

Trying to do repeat math on multiple variables...

David Fletcher already showed the best way of doing this, which is to use MATLAB efficiently with one numeric array. If you real...

2 days ago | 0

Answered

Working with inputs in functions

See these for examples of how to use |str2func|: <https://www.mathworks.com/matlabcentral/answers/337479-how-to-multiply-two-...

Working with inputs in functions

See these for examples of how to use |str2func|: <https://www.mathworks.com/matlabcentral/answers/337479-how-to-multiply-two-...

2 days ago | 0

Answered

How can I show variable index in a for loop?

_"I have 100 matrices, name x1, x2, ..., x100. I want to do the below process for all 100 variables using a "for loop""_ Acce...

How can I show variable index in a for loop?

_"I have 100 matrices, name x1, x2, ..., x100. I want to do the below process for all 100 variables using a "for loop""_ Acce...

4 days ago | 0

| accepted

Answered

Divide a matrix with an array along a specific dimension

Once you make the sizes compatible you can do this using standard methods without any loop. Use |permute| or |reshape| to get th...

Divide a matrix with an array along a specific dimension

Once you make the sizes compatible you can do this using standard methods without any loop. Use |permute| or |reshape| to get th...

4 days ago | 0

| accepted

Answered

Split number into parts

If the minutes always has exactly two digits then this can be easily solved using a <https://www.mathworks.com/help/matlab/matla...

Split number into parts

If the minutes always has exactly two digits then this can be easily solved using a <https://www.mathworks.com/help/matlab/matla...

4 days ago | 0

| accepted

Answered

Get exact indices of max value in 3D matrix

Use <https://www.mathworks.com/help/matlab/ref/ind2sub.html |ind2sub|>: >> A(:,:,1) = [30 31 32 33 34]; >> A(:,:,2) = [2...

Get exact indices of max value in 3D matrix

Use <https://www.mathworks.com/help/matlab/ref/ind2sub.html |ind2sub|>: >> A(:,:,1) = [30 31 32 33 34]; >> A(:,:,2) = [2...

6 days ago | 0

| accepted

Answered

Swapping numbers of two arrays when one is greater than the other

This is MATLAB, so loops and |if|'s are not required: >> Length = [1;5;7]; >> Width = [3;6;4]; >> tmp = sort([Length...

Swapping numbers of two arrays when one is greater than the other

This is MATLAB, so loops and |if|'s are not required: >> Length = [1;5;7]; >> Width = [3;6;4]; >> tmp = sort([Length...

6 days ago | 0

Answered

Convert large cell array to double

_"But when I want convert large model with degree and order for example 2200 (about 2 500 000 lines), code crashed on the third ...

Convert large cell array to double

_"But when I want convert large model with degree and order for example 2200 (about 2 500 000 lines), code crashed on the third ...

6 days ago | 0

| accepted

Answered

write char array and num to textfile using fprintf

>> a = ['ab';'cd']; >> b = [1;2]; >> c = [cellstr(a),num2cell(b)].'; >> fprintf('%s; %f\n',c{:}) ab; 1.000000 c...

write char array and num to textfile using fprintf

>> a = ['ab';'cd']; >> b = [1;2]; >> c = [cellstr(a),num2cell(b)].'; >> fprintf('%s; %f\n',c{:}) ab; 1.000000 c...

6 days ago | 0

| accepted

Answered

Combining duplicate entries in a data array

Use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> x = [0.1, 5, 5, 5, 14.5, 16, 16, 21]; >...

Combining duplicate entries in a data array

Use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> x = [0.1, 5, 5, 5, 14.5, 16, 16, 21]; >...

6 days ago | 1

| accepted

Answered

How to extract data from table variable names?

>> C = {'Rectum (4)(Volume: 57.77)','Bladder (5)(Volume: 139.40)'}; >> str2double(regexp(C,'\d+(\.\d+)?(?=\)$)','once','mat...

How to extract data from table variable names?

>> C = {'Rectum (4)(Volume: 57.77)','Bladder (5)(Volume: 139.40)'}; >> str2double(regexp(C,'\d+(\.\d+)?(?=\)$)','once','mat...

6 days ago | 0

Answered

How to convert string to number and process underscores? (e.g. '57_77_' to 57.77)

Faster and more efficient than using |str2num| (which hides a slow |eval| call inside) is to simply use the low-level function <...

How to convert string to number and process underscores? (e.g. '57_77_' to 57.77)

Faster and more efficient than using |str2num| (which hides a slow |eval| call inside) is to simply use the low-level function <...

6 days ago | 1

| accepted

Answered

I keep getting "Undefined operator '*' for input arguments of type 'cell' " when I run this code.

<https://www.mathworks.com/help/matlab/ref/inputdlg.html |inputdlg|> returns a cell array of character vectors, which as the err...

I keep getting "Undefined operator '*' for input arguments of type 'cell' " when I run this code.

<https://www.mathworks.com/help/matlab/ref/inputdlg.html |inputdlg|> returns a cell array of character vectors, which as the err...

6 days ago | 0

Answered

Help to improve runtime of 3 dimensional matrix

Your code is hugely inefficient because you expand the output array on each iteration. Read this to know more about why that is ...

Help to improve runtime of 3 dimensional matrix

Your code is hugely inefficient because you expand the output array on each iteration. Read this to know more about why that is ...

6 days ago | 1

| accepted

Answered

Why is ga optimization ridiculously slow to solve a problem ?

_"Therefore, in my mind, ga should look up for the minimal value by trying to set the variable with 10 11 12 13 14 15 16 only."_...

Why is ga optimization ridiculously slow to solve a problem ?

_"Therefore, in my mind, ga should look up for the minimal value by trying to set the variable with 10 11 12 13 14 15 16 only."_...

7 days ago | 2

| accepted

Answered

help debugging my script?

You wrote a |while| condition that will never be true. Have a look at this line: while n <= n-2 For what values of |n| c...

help debugging my script?

You wrote a |while| condition that will never be true. Have a look at this line: while n <= n-2 For what values of |n| c...

7 days ago | 0

| accepted

Answered

How to check the condition of both &(and), |(OR) operation in a single line ?

Always use |all| or |any| when using arrays of values with |if|, e.g.: any(-35==Vx(1,1:3)) && any(0==Vy(1,1:3))

How to check the condition of both &(and), |(OR) operation in a single line ?

Always use |all| or |any| when using arrays of values with |if|, e.g.: any(-35==Vx(1,1:3)) && any(0==Vy(1,1:3))

7 days ago | 1

| accepted

Answered

how to save every iteration into workspace

Use <https://www.mathworks.com/help/matlab/ref/fullfile.html |fullfile|> rather than string concatenation. To store the imported...

how to save every iteration into workspace

Use <https://www.mathworks.com/help/matlab/ref/fullfile.html |fullfile|> rather than string concatenation. To store the imported...

8 days ago | 1

| accepted