Answered

Check if cell contains only certain combination of variables

You can do this with an "exclusive or" (see xor) where you check that you have exlusively either 'A' or 'B' xor 'C' or 'D', but ...

Check if cell contains only certain combination of variables

You can do this with an "exclusive or" (see xor) where you check that you have exlusively either 'A' or 'B' xor 'C' or 'D', but ...

8 maanden ago | 0

| accepted

Answered

Divide the 3D feature space into grid and then get their labels

Example in 2D % Data x = rand(1,100)*10; y = rand(1,100)*5; r = zeros(size(x)); % group index r(x>0 & x<=5 & y>0 & y...

Divide the 3D feature space into grid and then get their labels

Example in 2D % Data x = rand(1,100)*10; y = rand(1,100)*5; r = zeros(size(x)); % group index r(x>0 & x<=5 & y>0 & y...

8 maanden ago | 1

| accepted

Answered

Reformat table with a column as a top row

You can reorganise the data pretty close to what you showed using unstack, but to get the header organised as you have shown wou...

Reformat table with a column as a top row

You can reorganise the data pretty close to what you showed using unstack, but to get the header organised as you have shown wou...

9 maanden ago | 0

| accepted

Answered

How could I make a callback that updates when the user moves an roi?

This is what I had in mind: interactiveZoomDemo; function [] = interactiveZoomDemo() I = imread('saturn.png'); hf = figu...

How could I make a callback that updates when the user moves an roi?

This is what I had in mind: interactiveZoomDemo; function [] = interactiveZoomDemo() I = imread('saturn.png'); hf = figu...

9 maanden ago | 0

| accepted

Answered

How to decrease margins around uibutton in uigridlayout?

Use the ColumnSpacing property: g.ColumnSpacing = 1;

How to decrease margins around uibutton in uigridlayout?

Use the ColumnSpacing property: g.ColumnSpacing = 1;

9 maanden ago | 0

| accepted

Answered

How to create rainbow colormap with violet

Violet is approximately [0.5 0 1] in the rgb space. So we can modify the blue part of the jet colormap, to have a bit more red ...

How to create rainbow colormap with violet

Violet is approximately [0.5 0 1] in the rgb space. So we can modify the blue part of the jet colormap, to have a bit more red ...

9 maanden ago | 0

Answered

Save an image from a matrix

Here's one way - convert to an 8 bit array with values between 0 and 255 and then save: I2 = 255*(I - min(I(:))) ./ (max(I(:)) ...

Save an image from a matrix

Here's one way - convert to an 8 bit array with values between 0 and 255 and then save: I2 = 255*(I - min(I(:))) ./ (max(I(:)) ...

9 maanden ago | 1

| accepted

Answered

Would it be possible to change the greyscale to a blue scale?

I don't think MATLAB has a blue scale colormap. You could do something custom, like the following. I'll use camerman for illustr...

Would it be possible to change the greyscale to a blue scale?

I don't think MATLAB has a blue scale colormap. You could do something custom, like the following. I'll use camerman for illustr...

9 maanden ago | 0

| accepted

Answered

How to get integer pixel coordinates from roi rectangle?

When used on images, the drawrectangle function uses intrinsic image coordinates (see this documentation) as shown by the x and ...

How to get integer pixel coordinates from roi rectangle?

When used on images, the drawrectangle function uses intrinsic image coordinates (see this documentation) as shown by the x and ...

9 maanden ago | 0

| accepted

Answered

Assign dimensions for my image. I have an image and I need to give it a length that I know.

The imref2d object is useful for exactly this. Let's have a look at an example: % Example of a Binary image BW = imbinarize(im...

Assign dimensions for my image. I have an image and I need to give it a length that I know.

The imref2d object is useful for exactly this. Let's have a look at an example: % Example of a Binary image BW = imbinarize(im...

9 maanden ago | 0

Answered

No effect of the FaceLighting property on a single patch?

There are two reasons. First is that you need to add a light object to the axes. To do that, use the light function. The secon...

No effect of the FaceLighting property on a single patch?

There are two reasons. First is that you need to add a light object to the axes. To do that, use the light function. The secon...

9 maanden ago | 2

| accepted

Answered

How can I find distance in a binarized image

I originally answered this for the case of the binary image you represented in png format (this is not technically a binary imag...

How can I find distance in a binarized image

I originally answered this for the case of the binary image you represented in png format (this is not technically a binary imag...

9 maanden ago | 2

| accepted

Answered

how do i deduce the function using linear regression for a set of x and y values?

Consider using a power fit. Your data: x = readmatrix('https://uk.mathworks.com/matlabcentral/answers/uploaded_files/850570/x2...

how do i deduce the function using linear regression for a set of x and y values?

Consider using a power fit. Your data: x = readmatrix('https://uk.mathworks.com/matlabcentral/answers/uploaded_files/850570/x2...

9 maanden ago | 1

| accepted

Answered

I need to make a general code

Try this: function [idx,x] = chaoticInterleaver(N) assert(mod(N,8)==0,'N must be divisible by 8.') idx = zeros(N); x = N * (...

I need to make a general code

Try this: function [idx,x] = chaoticInterleaver(N) assert(mod(N,8)==0,'N must be divisible by 8.') idx = zeros(N); x = N * (...

9 maanden ago | 0

| accepted

Answered

Rearrange a correlation matrix into a vector and keep track of the corr names.

You can get the corresponding row and column indices as follows: [iRow, iCol] = find(ind); Then you can get the corresponding ...

Rearrange a correlation matrix into a vector and keep track of the corr names.

You can get the corresponding row and column indices as follows: [iRow, iCol] = find(ind); Then you can get the corresponding ...

10 maanden ago | 0

| accepted

Answered

Properly centering interquartile ranges on graphed data

You can use the quantile function Your simulation: clc clearvars %Total number of replicates nr=1000; %Time step and lengt...

Properly centering interquartile ranges on graphed data

You can use the quantile function Your simulation: clc clearvars %Total number of replicates nr=1000; %Time step and lengt...

10 maanden ago | 0

| accepted

Answered

Converting a 2d array into a 3d array

You could write a linear index for the diagonal elements as follows: [m,n] = size(Z_int) Z = zeros(m,m,n); idx = repmat((1:...

Converting a 2d array into a 3d array

You could write a linear index for the diagonal elements as follows: [m,n] = size(Z_int) Z = zeros(m,m,n); idx = repmat((1:...

10 maanden ago | 0

Answered

Image cropping in exact cordinate in cell array

You can make the following modification (make sure to place your cellfun calls after the for loop) cropped_imgs = cellfun(@(I) ...

Image cropping in exact cordinate in cell array

You can make the following modification (make sure to place your cellfun calls after the for loop) cropped_imgs = cellfun(@(I) ...

10 maanden ago | 1

| accepted

Answered

Count instances of subarray inside array

You could do the following: b = A == 2; % binary indicating where A equal to 2 count = 0; ii = 1; while ii < numel(A) i...

Count instances of subarray inside array

You could do the following: b = A == 2; % binary indicating where A equal to 2 count = 0; ii = 1; while ii < numel(A) i...

11 maanden ago | 0

Answered

remove rows in table based on criteria across two columns

Try the following: T(contains(string(T{:,1}),'80ms,140ms') & T{:,2} ~= 1,:) = []; T(contains(string(T{:,1}),'100ms,250ms') & T...

remove rows in table based on criteria across two columns

Try the following: T(contains(string(T{:,1}),'80ms,140ms') & T{:,2} ~= 1,:) = []; T(contains(string(T{:,1}),'100ms,250ms') & T...

11 maanden ago | 0

| accepted

Answered

Clone GitHub repository - Authentication Failed

You need to follow the steps described <https://uk.mathworks.com/help/matlab/matlab_prog/set-up-git-source-control.html#mw_77963...

Clone GitHub repository - Authentication Failed

You need to follow the steps described <https://uk.mathworks.com/help/matlab/matlab_prog/set-up-git-source-control.html#mw_77963...

11 maanden ago | 0

Answered

how do i store for loop values?

There's only one value because your code is working as follows: for ii = 1:3 A = ii + 1 end Matlab is not told where to ...

how do i store for loop values?

There's only one value because your code is working as follows: for ii = 1:3 A = ii + 1 end Matlab is not told where to ...

ongeveer een jaar ago | 0

| accepted

Answered

Cannot obtain structure elements where both field and variable are indexed into

Try the following: students(1).name='john'; students(2).name='andrea'; arrayfun(@(x) students(x).name(1), 1:2).'

Cannot obtain structure elements where both field and variable are indexed into

Try the following: students(1).name='john'; students(2).name='andrea'; arrayfun(@(x) students(x).name(1), 1:2).'

ongeveer een jaar ago | 0

| accepted

Answered

I wanted to 3D plot my data like shown in attached image.

Use <https://uk.mathworks.com/help/matlab/ref/surf.html surf()> or doc surf there are several examples at both locatio...

I wanted to 3D plot my data like shown in attached image.

Use <https://uk.mathworks.com/help/matlab/ref/surf.html surf()> or doc surf there are several examples at both locatio...

ongeveer een jaar ago | 0

Answered

how to convert from grayscale to rgb by lightness method ??

You can do the following: I=imread('peppers.png'); newImage = uint8(( double(min(I,[],3)) + double(max(I,[],3)) ) ./ 2); im...

how to convert from grayscale to rgb by lightness method ??

You can do the following: I=imread('peppers.png'); newImage = uint8(( double(min(I,[],3)) + double(max(I,[],3)) ) ./ 2); im...

ongeveer een jaar ago | 0

| accepted

Answered

evaluate rising edge sample of a signal

Is it just the local minima you're having trouble with? Edit: The rising edge is found where the slope of the original data ...

evaluate rising edge sample of a signal

Is it just the local minima you're having trouble with? Edit: The rising edge is found where the slope of the original data ...

ongeveer een jaar ago | 0

| accepted

Answered

How to marker a fplot(anonymous function) function on a specific point which user enters.

You can add it in at the end of your function using plot: function x=calcDisplacement(t) m=1100; k=570; c=430; x0=0.05; v0...

How to marker a fplot(anonymous function) function on a specific point which user enters.

You can add it in at the end of your function using plot: function x=calcDisplacement(t) m=1100; k=570; c=430; x0=0.05; v0...

ongeveer een jaar ago | 0

| accepted

Answered

how to select and save particulat part of a column in mat file?

columns = [2 3 5]; rows = 50:100; x = mydata(rows,columns); save('mydata.mat','x')

how to select and save particulat part of a column in mat file?

columns = [2 3 5]; rows = 50:100; x = mydata(rows,columns); save('mydata.mat','x')

ongeveer een jaar ago | 1

| accepted

Answered

How to save data in a vector for each loop indice?

x = 1:0.1:1.5; vec=zeros(size(x)); for ii = 1:numel(x) sol = x(ii)+1; vec(ii)=sol; end vec

How to save data in a vector for each loop indice?

x = 1:0.1:1.5; vec=zeros(size(x)); for ii = 1:numel(x) sol = x(ii)+1; vec(ii)=sol; end vec

ongeveer een jaar ago | 1

| accepted

Answered

Random values in timetable

You can collect the data in the loop and then use timetable n = 1; for i = 1:5 Time(i,1) = datetime('now'); Conducti...

Random values in timetable

You can collect the data in the loop and then use timetable n = 1; for i = 1:5 Time(i,1) = datetime('now'); Conducti...

ongeveer een jaar ago | 2