Email: feel free to contact me regarding my shared files on the file exchange. I don't do free consulting outside of the forum so if you have a Matlab question, post the question to the forum and you may email me the link to the question.

About me: Finishing PhD soon on topics related to vision science; neurophysiology; sensory-motor feedback and control; control systems; steering & navigation; multisensory integration; top-down bottom-up feedback loop.

"If I had only one hour to save the world, I would spend fifty-five minutes defining the problem, and only five minutes finding the solution." -Albert Einstein

"An expert is a person who has made all the mistakes that can be made in a very narrow field." -Niels Bohr

"If you are not embarrassed by the first version of your product, you've launched too late" - Reid Hoffman

Answered

Add legend to mutiple figures in a loop with conditional

I agree with Mario that you just have to provide the axis handle to specify where each legend goes. But there's some other stuf...

Add legend to mutiple figures in a loop with conditional

I agree with Mario that you just have to provide the axis handle to specify where each legend goes. But there's some other stuf...

1 hour ago | 0

Answered

Percentage values in scatterhist histogram

The histograms are normalized which means their bar heights are already a percentage. The percentage of each bar can be found ...

Percentage values in scatterhist histogram

The histograms are normalized which means their bar heights are already a percentage. The percentage of each bar can be found ...

3 days ago | 0

Answered

what do '--' and '-.' mean?

These are line styles. Also check out the LineSpec input to the plot function. plot(X,Y,LineSpec)

what do '--' and '-.' mean?

These are line styles. Also check out the LineSpec input to the plot function. plot(X,Y,LineSpec)

4 days ago | 0

| accepted

Answered

Maximum likelihood with Heteroskedasticity

You are suffering from the side effects of using global variables (incorrectly). Don't use global variables in Matlab. Ins...

Maximum likelihood with Heteroskedasticity

You are suffering from the side effects of using global variables (incorrectly). Don't use global variables in Matlab. Ins...

4 days ago | 0

| accepted

Answered

Changing transparency of individual bars in bar

You can plot the bars one at a time or in groups that all have the same FaceAlpha level. That way the bars with differen alpha...

Changing transparency of individual bars in bar

You can plot the bars one at a time or in groups that all have the same FaceAlpha level. That way the bars with differen alpha...

4 days ago | 1

| accepted

Answered

Removing rows duplicates based on some conditions

Method 1 Here's a simple solution that assumes matching rows in columns 1:3 are next to each other. The assert command tests t...

Removing rows duplicates based on some conditions

Method 1 Here's a simple solution that assumes matching rows in columns 1:3 are next to each other. The assert command tests t...

4 days ago | 0

Answered

Fit a line to data using regress

b = regress(y,x) If x and y are vectors, they must be column vectors regress(y(:),x(:)) For alternatives, see https://www....

Fit a line to data using regress

b = regress(y,x) If x and y are vectors, they must be column vectors regress(y(:),x(:)) For alternatives, see https://www....

4 days ago | 0

Answered

a small problem with linspace

11981420 is not divisible by 40. 11981420/40 ans = 2.9954e+05 % = 299535.5 size(s) ans = 1 299535 29...

a small problem with linspace

11981420 is not divisible by 40. 11981420/40 ans = 2.9954e+05 % = 299535.5 size(s) ans = 1 299535 29...

4 days ago | 0

| accepted

Answered

How do I change the colour of certain indices in scatterplot?

Here's are 4 demo that all achieve the same result. Xvals = [1,2,3,4,5,6,7,8,9]; Yvals = [2,5,5,5,2,2,5,5,5]; % Show scatt...

How do I change the colour of certain indices in scatterplot?

Here's are 4 demo that all achieve the same result. Xvals = [1,2,3,4,5,6,7,8,9]; Yvals = [2,5,5,5,2,2,5,5,5]; % Show scatt...

4 days ago | 0

| accepted

Answered

How to find what number is missing from a range inside of an array?

Check out Lia = ismember(A,B) Example full = [1;2;3;4;5]; sample = [2;4;5]; idx = ismember(full, sample); full(~idx)

How to find what number is missing from a range inside of an array?

Check out Lia = ismember(A,B) Example full = [1;2;3;4;5]; sample = [2;4;5]; idx = ismember(full, sample); full(~idx)

4 days ago | 0

| accepted

Answered

Disable app while calculating

How to disable app components while app is busy List all components you'd like to disable/enable in a vector of handles. Impor...

Disable app while calculating

How to disable app components while app is busy List all components you'd like to disable/enable in a vector of handles. Impor...

4 days ago | 1

Answered

How to transparent histogram or mix colors of different histograms

Set the FaceAlpha and EdgeAlpha values to something like 0.5. The reason you're not seeing any transparency even though you're ...

How to transparent histogram or mix colors of different histograms

Set the FaceAlpha and EdgeAlpha values to something like 0.5. The reason you're not seeing any transparency even though you're ...

4 days ago | 1

| accepted

Answered

How can I save UIAxes as an image when button is pushed in app designer?

The code you shared shows that you're exporting the children of a UIAxes onto a regular axis. That can be done with copyUIAxe...

How can I save UIAxes as an image when button is pushed in app designer?

The code you shared shows that you're exporting the children of a UIAxes onto a regular axis. That can be done with copyUIAxe...

4 days ago | 0

Answered

I want to implement an end point detection for a tall spike in a sound signal

"only one should be the true "tall" peak (the first peak read in the data)" Are you sure about that? That's this peak in the da...

I want to implement an end point detection for a tall spike in a sound signal

"only one should be the true "tall" peak (the first peak read in the data)" Are you sure about that? That's this peak in the da...

4 days ago | 1

| accepted

Answered

Error using cross validation with plsregress

Based on the results of which crossval -all a function with the same name from a 3rd party toolbox (pls toolbox) is shadowing...

Error using cross validation with plsregress

Based on the results of which crossval -all a function with the same name from a 3rd party toolbox (pls toolbox) is shadowing...

4 days ago | 0

Answered

"Array indices must be positive integers or logical values."

If this is the complete script, the error is caused in this line where i is not defined and therefore takes the default value of...

"Array indices must be positive integers or logical values."

If this is the complete script, the error is caused in this line where i is not defined and therefore takes the default value of...

5 days ago | 0

| accepted

Answered

how can I plot 800 samples in a percentage cicle from 0 to 100% on x axis?

If you wanted to normalize the X values (Sp) so that they span from 0 to 100, SpNorm = (Sp-min(Sp))./range(Sp)*100; plot(SpN...

how can I plot 800 samples in a percentage cicle from 0 to 100% on x axis?

If you wanted to normalize the X values (Sp) so that they span from 0 to 100, SpNorm = (Sp-min(Sp))./range(Sp)*100; plot(SpN...

5 days ago | 0

| accepted

Answered

Is there a way to return the status of writetable, writematrix, or writecell?

"Is there a way to return the status of writetable, writematrix, or writecell?" No. But there are workarounds depending on how...

Is there a way to return the status of writetable, writematrix, or writecell?

"Is there a way to return the status of writetable, writematrix, or writecell?" No. But there are workarounds depending on how...

5 days ago | 0

| accepted

Answered

how can i declare a variable in a function for the first time only ,

I think this is what you're looking for, function h=src(input) persistent output %%%%%%%% if isempty(output) ...

how can i declare a variable in a function for the first time only ,

I think this is what you're looking for, function h=src(input) persistent output %%%%%%%% if isempty(output) ...

5 days ago | 1

| accepted

Answered

decreasing three loops to two loops with sum

----------- Updated answer ------------------------------ Vectorize the k-loop and use sum() to define theta2. thetao=1; alfa...

decreasing three loops to two loops with sum

----------- Updated answer ------------------------------ Vectorize the k-loop and use sum() to define theta2. thetao=1; alfa...

5 days ago | 0

| accepted

Answered

error: Index in position 2 exceeds array bounds (must not exceed 2).

The error is happening here squeeze(V0_1(ik2, iter+1)') % or, V0_1( 1 , 15 ) V0_1 is 101 x 2. iter is equal to 14 on th...

error: Index in position 2 exceeds array bounds (must not exceed 2).

The error is happening here squeeze(V0_1(ik2, iter+1)') % or, V0_1( 1 , 15 ) V0_1 is 101 x 2. iter is equal to 14 on th...

5 days ago | 0

| accepted

Answered

How do I change the font size of the axes in a stacked plot?

Use the stackedplot handle. h = stackedplot(T); h.FontSize = 12; % or set(h, 'FontSize', 12) If you don't have access...

How do I change the font size of the axes in a stacked plot?

Use the stackedplot handle. h = stackedplot(T); h.FontSize = 12; % or set(h, 'FontSize', 12) If you don't have access...

5 days ago | 0

Answered

How could I read Index number of a third column matrix using elements of first two matrices and write them as a row matrix?

Use logical indexing which is similar to what you're already doing but without the find(). That way all of the index vectors wil...

How could I read Index number of a third column matrix using elements of first two matrices and write them as a row matrix?

Use logical indexing which is similar to what you're already doing but without the find(). That way all of the index vectors wil...

5 days ago | 0

Answered

Index months in timetable

Logical index of rows that are in July,Aug,Sept. idx = ismember(month(TT2_staLCA_WS.Time),[7,8,9]);

Index months in timetable

Logical index of rows that are in July,Aug,Sept. idx = ismember(month(TT2_staLCA_WS.Time),[7,8,9]);

5 days ago | 0

| accepted

Answered

Legend Positioning in Tiled Chart Layout

" MATLAB 2019b ... has locked the 'Position' property of the legend when usend in a tiled chart." Yes, that's correct. Starti...

Legend Positioning in Tiled Chart Layout

" MATLAB 2019b ... has locked the 'Position' property of the legend when usend in a tiled chart." Yes, that's correct. Starti...

5 days ago | 0

Answered

How can I create a function that converts the number of a month to the name of a month?

No need to create a function for that. Monthnumber = 4; M = month(datetime(1, Monthnumber, 1), 'Name') % also try 'shortname...

How can I create a function that converts the number of a month to the name of a month?

No need to create a function for that. Monthnumber = 4; M = month(datetime(1, Monthnumber, 1), 'Name') % also try 'shortname...

6 days ago | 0

Answered

Creating Table from Cell Array Data

The first version in your question doesn't work because "names" contain 3 VariableNames that are all "Bin1" so when you assign t...

Creating Table from Cell Array Data

The first version in your question doesn't work because "names" contain 3 VariableNames that are all "Bin1" so when you assign t...

6 days ago | 1

| accepted

Answered

How can I pass a variable between a m-file and another m-file that runs a gui?

M files can contain scripts or functions but variables can only be passed to functions so the m-file must be written as a functi...

How can I pass a variable between a m-file and another m-file that runs a gui?

M files can contain scripts or functions but variables can only be passed to functions so the m-file must be written as a functi...

6 days ago | 0

| accepted

Answered

How do i create a colour quiver plot (colquiver) on top of a pcolor depth map?

"How can I ... use 2 colourmaps and have 2 colourbars?" An axis can have more than 1 colorbar but it cannot have more than 1 co...

How do i create a colour quiver plot (colquiver) on top of a pcolor depth map?

"How can I ... use 2 colourmaps and have 2 colourbars?" An axis can have more than 1 colorbar but it cannot have more than 1 co...

6 days ago | 0

| accepted

Answered

Velocity vector plot with empty cell array

We can't run your code due to missing variables but here are two general suggestions. Before before we get to that, always p...

Velocity vector plot with empty cell array

We can't run your code due to missing variables but here are two general suggestions. Before before we get to that, always p...

6 days ago | 0