144 total contributions since 2016

Computer Scientist working in finance.

Likes cherries in graphs.

Answered

How to fix: Index Exceeds Matrix Dimensions

P = 2 27 32 34 37 50 52 60 65 68 70 75 90 P+10 ans = 12 37 42...

How to fix: Index Exceeds Matrix Dimensions

P = 2 27 32 34 37 50 52 60 65 68 70 75 90 P+10 ans = 12 37 42...

mehr als 2 Jahre ago | 0

| accepted

Answered

How can I open the same program twice in matlab editor?

On the 'VIEW' tab the first section is 'TILES'. Select any of the options to view the same file in multiple sub-windows and edit...

How can I open the same program twice in matlab editor?

On the 'VIEW' tab the first section is 'TILES'. Select any of the options to view the same file in multiple sub-windows and edit...

mehr als 2 Jahre ago | 1

| accepted

Answered

Specific column range from an array?

y = x(5:10, 2) % rows 5:10, column 2 See more: <https://uk.mathworks.com/company/newsletters/articles/matrix-indexing-in-ma...

Specific column range from an array?

y = x(5:10, 2) % rows 5:10, column 2 See more: <https://uk.mathworks.com/company/newsletters/articles/matrix-indexing-in-ma...

fast 3 Jahre ago | 2

| accepted

Answered

Subscript indices problem with a for loop

|Altitude| is |0| in the first loop, which is not a valid index in this case. It is suspicious though that you assign a numer...

Subscript indices problem with a for loop

|Altitude| is |0| in the first loop, which is not a valid index in this case. It is suspicious though that you assign a numer...

fast 3 Jahre ago | 0

Answered

How to create a numerical variable from a string stored in a cell array ?

To get the numeric values: country_idx = findgroups(countrycode); For the second part, it really depends on what is it e...

How to create a numerical variable from a string stored in a cell array ?

To get the numeric values: country_idx = findgroups(countrycode); For the second part, it really depends on what is it e...

fast 3 Jahre ago | 0

| accepted

Answered

How to operate on a specified parts of a matrix in a loop?

It would depend on the particular 'operation'. If your 'operation' works on a 10*50 matrix, and for example produces a scalar va...

How to operate on a specified parts of a matrix in a loop?

It would depend on the particular 'operation'. If your 'operation' works on a 10*50 matrix, and for example produces a scalar va...

fast 3 Jahre ago | 1

| accepted

Answered

Split Column into 3 Columns

If your 1181*4 matrix is |m|: res = [floor(m(:,1)/10000), floor(mod(m(:,1), 10000)/100), (m(:,1))]; Alternatively, you c...

Split Column into 3 Columns

If your 1181*4 matrix is |m|: res = [floor(m(:,1)/10000), floor(mod(m(:,1), 10000)/100), (m(:,1))]; Alternatively, you c...

fast 3 Jahre ago | 0

Answered

Convert cell array to numeric data

cellfun(@str2num, tt) will do the trick, |cellfun| applies |str2num| to every cell.

Convert cell array to numeric data

cellfun(@str2num, tt) will do the trick, |cellfun| applies |str2num| to every cell.

fast 3 Jahre ago | 2

Answered

how to fix the error "Undefined function or variable 'superpixels'." ?

This error is very self-explanatory: |superpixels| is not a variable that is defined for the scope, nor it is a function name th...

how to fix the error "Undefined function or variable 'superpixels'." ?

This error is very self-explanatory: |superpixels| is not a variable that is defined for the scope, nor it is a function name th...

fast 3 Jahre ago | 0

Answered

Help in troubleshooting a code

|dec2hec| results in a char array of 1*n for each |(i,j)| pair, which then would not fit into one element of the numeric array |...

Help in troubleshooting a code

|dec2hec| results in a char array of 1*n for each |(i,j)| pair, which then would not fit into one element of the numeric array |...

fast 3 Jahre ago | 0

| accepted

Answered

Undefined operator '==' for input arguments of type 'struct'.

It means |f| or |iregion| is a struct, and the |'=='| operator is not defined for that type. for structs, you can use |isequal| ...

Undefined operator '==' for input arguments of type 'struct'.

It means |f| or |iregion| is a struct, and the |'=='| operator is not defined for that type. for structs, you can use |isequal| ...

fast 3 Jahre ago | 0

| accepted

Answered

how to save output of for loop

The size of output |S| in this case will be |54*20|. To specify that you want to assign |answer| to the whole row of |S|, use th...

how to save output of for loop

The size of output |S| in this case will be |54*20|. To specify that you want to assign |answer| to the whole row of |S|, use th...

fast 3 Jahre ago | 2

| accepted

Answered

a(a(a>3)<10) = OK ; a(a>3 && a<10) = wrong!, the correct way?

If you want to get only values between 3 and 10 (excluding the endpoints), the correct way would be: a(a>3 & a<10) (Not ...

a(a(a>3)<10) = OK ; a(a>3 && a<10) = wrong!, the correct way?

If you want to get only values between 3 and 10 (excluding the endpoints), the correct way would be: a(a>3 & a<10) (Not ...

fast 3 Jahre ago | 1

| accepted

Answered

How to save persistent variables after the last call to the function?

Without using the |save| command the |persistent| variables could be declared as persistent when calling from a function, as exp...

How to save persistent variables after the last call to the function?

Without using the |save| command the |persistent| variables could be declared as persistent when calling from a function, as exp...

fast 3 Jahre ago | 0

Solved

Sum of diagonal of a square matrix

If x = [1 2 4; 3 4 5; 5 6 7] then y should be the sum of the diagonals of the matrix y = 1 + 4 + 7 = 12

fast 3 Jahre ago

Solved

Is my wife right? Now with even more wrong husband

Again, as in "Is my wife right?" ( <http://www.mathworks.com/matlabcentral/cody/problems/149-is-my-wife-right> ), answer 'yes' r...

fast 3 Jahre ago

Answered

adding next values in an array

Considering the last element on a column will not be added to any other elements, you can loop through the whole thing: fun...

adding next values in an array

Considering the last element on a column will not be added to any other elements, you can loop through the whole thing: fun...

fast 3 Jahre ago | 0

Answered

About Preallocating for speed

NumberedOD = nchoosek(1:N, 2);

About Preallocating for speed

NumberedOD = nchoosek(1:N, 2);

fast 3 Jahre ago | 3

| accepted

Answered

finding and changing values in matrix that satisfies 2 conditions

idx = find(A); % find indices of nonzero elements in A B = A; % initially set B to be same as A B(idx(2:2:end)) = 100;

finding and changing values in matrix that satisfies 2 conditions

idx = find(A); % find indices of nonzero elements in A B = A; % initially set B to be same as A B(idx(2:2:end)) = 100;

fast 3 Jahre ago | 0

Answered

How to use IF statements for matrices correctly?

What MATLAB version are you using? Are you sure Example 4 gives a different result than Example 3? This works 'properly', as...

How to use IF statements for matrices correctly?

What MATLAB version are you using? Are you sure Example 4 gives a different result than Example 3? This works 'properly', as...

fast 3 Jahre ago | 1

Answered

How to convert binary elements of a cell into decimal number

Considering it's a 1*1624 numeric array you have in the cell |A|, you can utilise |bin2dec| to do it after converting the numeri...

How to convert binary elements of a cell into decimal number

Considering it's a 1*1624 numeric array you have in the cell |A|, you can utilise |bin2dec| to do it after converting the numeri...

fast 3 Jahre ago | 0

Answered

Setting a limit in an array

Given initial matrix |F|, this will floor entries at 30 in between z 'axis' (from and including) 40 and 50: F(:,:,40:50) = ...

Setting a limit in an array

Given initial matrix |F|, this will floor entries at 30 in between z 'axis' (from and including) 40 and 50: F(:,:,40:50) = ...

fast 3 Jahre ago | 1

| accepted

Answered

How can I use a string input in a "for" loop to get a matrix of names?

The problem with this code is that (in MATLAB) indexing is from |1|, not |0|. Therefore |a(0)| is giving you the error. As fo...

How can I use a string input in a "for" loop to get a matrix of names?

The problem with this code is that (in MATLAB) indexing is from |1|, not |0|. Therefore |a(0)| is giving you the error. As fo...

fast 3 Jahre ago | 1

Answered

Finding a maximum period

If you're looking for the |n| highest and lowest entry for each row of input |data|, you can still use the sort function: [...

Finding a maximum period

If you're looking for the |n| highest and lowest entry for each row of input |data|, you can still use the sort function: [...

etwa 3 Jahre ago | 0

Answered

Finding NaN values in Structure

It is good practice to avoid |eval|: first_level = fieldnames(structure); counter = 0; % keep track of the found NaNs so...

Finding NaN values in Structure

It is good practice to avoid |eval|: first_level = fieldnames(structure); counter = 0; % keep track of the found NaNs so...

etwa 3 Jahre ago | 0

Answered

hourly average of data from 30mins past the hour

You could avoid the date conversion back-and-forth business by sticking to |DateNumber|. Getting not only the hours but the min...

hourly average of data from 30mins past the hour

You could avoid the date conversion back-and-forth business by sticking to |DateNumber|. Getting not only the hours but the min...

etwa 3 Jahre ago | 0

Answered

Write a single for statement to print the letters ‘A’ to ‘Z’ each 10 letters on a separate line.

count = 1; for array = char(double('A'):double('Z')) % create character array from 'A' to 'Z' fprintf('%s', array); ...

Write a single for statement to print the letters ‘A’ to ‘Z’ each 10 letters on a separate line.

count = 1; for array = char(double('A'):double('Z')) % create character array from 'A' to 'Z' fprintf('%s', array); ...

etwa 3 Jahre ago | 0