Answered

Symmetric binary matrix with diagonal 0 values

Guaranteed to work on the first try: Msize = 10; %size of square matrix N = 20; %number of ones on each side of the diagonale...

Symmetric binary matrix with diagonal 0 values

Guaranteed to work on the first try: Msize = 10; %size of square matrix N = 20; %number of ones on each side of the diagonale...

circa 3 ore ago | 0

Answered

Change Matlab Version from R2014a to R2018a

If you're going to upgrade, you may as well upgrade to the latest version, currently R2019b. Code that worked in 2018a should wo...

Change Matlab Version from R2014a to R2018a

If you're going to upgrade, you may as well upgrade to the latest version, currently R2019b. Code that worked in 2018a should wo...

circa 5 ore ago | 0

Answered

Index exceeds the number of array elements. Please Help?

Does anyone have any idea why i get the following error on line 15 Because the x you passed has less than 300 elements. Since i...

Index exceeds the number of array elements. Please Help?

Does anyone have any idea why i get the following error on line 15 Because the x you passed has less than 300 elements. Since i...

circa 6 ore ago | 0

Answered

Output must be a column vector

It looks like your error message comes from an ODE solver. It's the ODE solver that calls your function, so it's unclear what yo...

Output must be a column vector

It looks like your error message comes from an ODE solver. It's the ODE solver that calls your function, so it's unclear what yo...

circa 6 ore ago | 0

Answered

Vectorisation of code for insertion of n x n matrices in a 3D array along the diagonal of a large matrix

Note: I don't see how you can get a 4 at M(2, 1) if maxRand is 3. Here is one way, no guarantee that it's faster than a loop. W...

Vectorisation of code for insertion of n x n matrices in a 3D array along the diagonal of a large matrix

Note: I don't see how you can get a 4 at M(2, 1) if maxRand is 3. Here is one way, no guarantee that it's faster than a loop. W...

circa 8 ore ago | 0

Answered

Timer Interrupt in App Designer

app.t.TimerFcn = @app.DisplayFPS; %<--DisplayFPS is a method of the app, so must be called with app argument

Timer Interrupt in App Designer

app.t.TimerFcn = @app.DisplayFPS; %<--DisplayFPS is a method of the app, so must be called with app argument

circa 10 ore ago | 1

| accepted

Answered

parking space using IMAGE PROCESSING

You've cut the error message and removed the most important bit, the last part which told you which line of your code is respons...

parking space using IMAGE PROCESSING

You've cut the error message and removed the most important bit, the last part which told you which line of your code is respons...

circa 11 ore ago | 0

| accepted

Answered

Adding elements of a matrix based on an if condition

There is no rblush in your code. Note that sum(scalar_value) is simply scalar_value. The code you've written does not work at a...

Adding elements of a matrix based on an if condition

There is no rblush in your code. Note that sum(scalar_value) is simply scalar_value. The code you've written does not work at a...

2 giorni ago | 0

Answered

Help with using summation functions in matlab (Trying to create an atomic scatter function)

function scatterfactor = calculatescatteringfactor(Z, s, a, b) assert(numel(s) == 1, 's must be scalar'); assert(isequ...

Help with using summation functions in matlab (Trying to create an atomic scatter function)

function scatterfactor = calculatescatteringfactor(Z, s, a, b) assert(numel(s) == 1, 's must be scalar'); assert(isequ...

2 giorni ago | 0

Answered

find second minimum in a row in matlab without sorting

Use mink A = [ 3.5 2 1.6 1.456 0 1.9 2.6 ; 3.8 2.6 3.9 0 6 1.564 0 ]; minvals = mink(A, 2, 2); %first 2 miminums along dimen...

find second minimum in a row in matlab without sorting

Use mink A = [ 3.5 2 1.6 1.456 0 1.9 2.6 ; 3.8 2.6 3.9 0 6 1.564 0 ]; minvals = mink(A, 2, 2); %first 2 miminums along dimen...

2 giorni ago | 1

Answered

How to read .txt file and convert the characters of .txt into cell formation

You ought to read the documentation of the functions you use if you don't know how they work. fopen doesn't read a file. All it ...

How to read .txt file and convert the characters of .txt into cell formation

You ought to read the documentation of the functions you use if you don't know how they work. fopen doesn't read a file. All it ...

2 giorni ago | 0

Answered

Reodering/Swapping Arrays in a struct

You seem to be writing matlab code using C syntax. In matlab if conditions don't need to be enclosed in () brackets if a(i) > 7...

Reodering/Swapping Arrays in a struct

You seem to be writing matlab code using C syntax. In matlab if conditions don't need to be enclosed in () brackets if a(i) > 7...

3 giorni ago | 0

| accepted

Answered

Are MATLAB updates supersed each other or we must install the whole packages?

Each update includes all the previous updates, you only need to install the latest even if you haven't installed the previous on...

Are MATLAB updates supersed each other or we must install the whole packages?

Each update includes all the previous updates, you only need to install the latest even if you haven't installed the previous on...

3 giorni ago | 0

Answered

How to convert a letter to a number in a cell array? Number = alphabetical order location. i.e. A = 1, B = 2, C = 3, etc.

cell2mat(yourcellarray) - 'A' + 1

How to convert a letter to a number in a cell array? Number = alphabetical order location. i.e. A = 1, B = 2, C = 3, etc.

cell2mat(yourcellarray) - 'A' + 1

3 giorni ago | 1

| accepted

Answered

using strrep multiple times

Use replace instead: >> usertext = 'left black left right up down upside white upleft'; >> replace(usertext, {'left', 'up', 'b...

using strrep multiple times

Use replace instead: >> usertext = 'left black left right up down upside white upleft'; >> replace(usertext, {'left', 'up', 'b...

3 giorni ago | 2

Answered

How can I pass variables to eval without error suppression ?

f = @() func(numel(b), a, b); %prepare function for call evalc('f()'); %call function. () optional but make it clear we're ca...

How can I pass variables to eval without error suppression ?

f = @() func(numel(b), a, b); %prepare function for call evalc('f()'); %call function. () optional but make it clear we're ca...

3 giorni ago | 2

| accepted

Answered

Find the orientation of each arbitrary object in an image

The structure (or table if you ask for table output) returned by regionprops has a field called 'Orientation' which is the angle...

Find the orientation of each arbitrary object in an image

The structure (or table if you ask for table output) returned by regionprops has a field called 'Orientation' which is the angle...

3 giorni ago | 1

Answered

Select elements of a matrix based on the values of a logical array

First, have you noticed that your code doesn't work at all? It either copy all of columns 3 and 4 of A into C if B is all 1s, an...

Select elements of a matrix based on the values of a logical array

First, have you noticed that your code doesn't work at all? It either copy all of columns 3 and 4 of A into C if B is all 1s, an...

3 giorni ago | 0

| accepted

Answered

Select specific number of random ones placed in a zeros matrix

m = zeros(1024, 1024); m(randperm(numel(m), 20)) = 1; %place 20 ones randomly in m.

Select specific number of random ones placed in a zeros matrix

m = zeros(1024, 1024); m(randperm(numel(m), 20)) = 1; %place 20 ones randomly in m.

4 giorni ago | 0

| accepted

Answered

how to read a string

split = textscan(tline, '%s%f%f%f'); txt = split{1} numbers = cell2mat(split(2:end))

how to read a string

split = textscan(tline, '%s%f%f%f'); txt = split{1} numbers = cell2mat(split(2:end))

4 giorni ago | 0

Answered

How do I track the number of instances of a given handle?

I'm curious what you mean by "inheriting that class appears to put a lot of constraints on what I can do with my existing code i...

How do I track the number of instances of a given handle?

I'm curious what you mean by "inheriting that class appears to put a lot of constraints on what I can do with my existing code i...

4 giorni ago | 0

Answered

How to get field value from a struct as a variable in order to use in a code?

There's no need to. Creating separate variables is usually not a good idea. Wherever you were going to use X, use yourstruct.X. ...

How to get field value from a struct as a variable in order to use in a code?

There's no need to. Creating separate variables is usually not a good idea. Wherever you were going to use X, use yourstruct.X. ...

4 giorni ago | 2

| accepted

Answered

Having trouble finding the mean of array elements between two indices

See my comments to the question. Using a matrix, and assuming you're using R2019b since you haven't indicated a matlab version:...

Having trouble finding the mean of array elements between two indices

See my comments to the question. Using a matrix, and assuming you're using R2019b since you haven't indicated a matlab version:...

4 giorni ago | 0

Answered

Add empty cell inside a cell array considering a single array

Surely, by now, with all the questions you've asked, you should be able to manipulate cell arrays yourself. Anyway: desiredlen...

Add empty cell inside a cell array considering a single array

Surely, by now, with all the questions you've asked, you should be able to manipulate cell arrays yourself. Anyway: desiredlen...

4 giorni ago | 0

| accepted

Answered

Is it possible to use a variable name like this within Matlab?

Confusingly, variable names can mean two different things now in matlab. A generic variable name, e.g. >> A = 5 is limited to ...

Is it possible to use a variable name like this within Matlab?

Confusingly, variable names can mean two different things now in matlab. A generic variable name, e.g. >> A = 5 is limited to ...

4 giorni ago | 2

| accepted

Answered

Why the threshold is 0.90 used to obtain the white component from RGB channels ?

You will have to ask whoever wrote that code why they chose that threshold. Most likely, the answer will be : because it worked...

Why the threshold is 0.90 used to obtain the white component from RGB channels ?

You will have to ask whoever wrote that code why they chose that threshold. Most likely, the answer will be : because it worked...

4 giorni ago | 0

Answered

How to index something based on numbering order???

Here is one way: %input x = [2; 3; 7; 5; 1] %generate random matrix without worrying about the order A = rand(size(x, 1),...

How to index something based on numbering order???

Here is one way: %input x = [2; 3; 7; 5; 1] %generate random matrix without worrying about the order A = rand(size(x, 1),...

4 giorni ago | 0

| accepted

Answered

How to assign specific colors to every quiver?

I can't remember if quiver did have children before R2014b (when the graphics system changed drastically) but since R2014b it do...

How to assign specific colors to every quiver?

I can't remember if quiver did have children before R2014b (when the graphics system changed drastically) but since R2014b it do...

5 giorni ago | 0

Answered

Why is my regular expression always greedy?

Matlab regex engine has the odd peculiarity that . also matches \n by default, whereas other engines don't. So your greedy .* in...

Why is my regular expression always greedy?

Matlab regex engine has the odd peculiarity that . also matches \n by default, whereas other engines don't. So your greedy .* in...

5 giorni ago | 0

| accepted

Answered

Using data from a cell

I need new variables created for each of the character vectors No! As Stephen already told you this would worst way to go about...

Using data from a cell

I need new variables created for each of the character vectors No! As Stephen already told you this would worst way to go about...

5 giorni ago | 0