E-mails with feedback/questions about FEX submissions are welcomed. In general I will post e-mails about Answers on the related page, unless there is good cause not to do so.

Answered

Recursion function in matlab

function n=I_call_myself(n) disp(n) if n>0 n=I_call_myself(n-1); else disp('n has reached 0') end end

Recursion function in matlab

function n=I_call_myself(n) disp(n) if n>0 n=I_call_myself(n-1); else disp('n has reached 0') end end

2 dagen ago | 0

Answered

saving all data from for loop after image processing

You should use the '-append' option if you don't want to overwrite your text file every iteration.

saving all data from for loop after image processing

You should use the '-append' option if you don't want to overwrite your text file every iteration.

2 dagen ago | 0

| accepted

Answered

Splitting an array up

You can modify the row indices you feed to mat2cell: data=rand(64,92690);%generate random data div=2048; c=div*ones(1,ceil(...

Splitting an array up

You can modify the row indices you feed to mat2cell: data=rand(64,92690);%generate random data div=2048; c=div*ones(1,ceil(...

2 dagen ago | 1

Answered

Ternary plot in MATLAB

The TrianglePlot function I posted on the FEX seems to work just fine (although I decreased the number of points for this exampl...

Ternary plot in MATLAB

The TrianglePlot function I posted on the FEX seems to work just fine (although I decreased the number of points for this exampl...

2 dagen ago | 0

Answered

Plot data for unique temperatures imported from text file

%% code starts here r_data = importdata('reactions.txt'); %reaction_data = r_data.data; %fid=fopen('reactions.txt'); t = rea...

Plot data for unique temperatures imported from text file

%% code starts here r_data = importdata('reactions.txt'); %reaction_data = r_data.data; %fid=fopen('reactions.txt'); t = rea...

2 dagen ago | 2

| accepted

Answered

Pair of dice always rolled until all results happened between (2-12) ..Expected value of throws to find

Since this is homework I won't give a complete solution, but I will give hints. If you have trouble implementing these, feel fre...

Pair of dice always rolled until all results happened between (2-12) ..Expected value of throws to find

Since this is homework I won't give a complete solution, but I will give hints. If you have trouble implementing these, feel fre...

2 dagen ago | 0

Answered

How can i extract the value of an element of a sparse double?

You can convert the result to a full matrix. Indexing only extracts part of the array, but doesn't influence the sparse property...

How can i extract the value of an element of a sparse double?

You can convert the result to a full matrix. Indexing only extracts part of the array, but doesn't influence the sparse property...

3 dagen ago | 1

Answered

How do you average each pixel in an image with a 9x9 square?

If you want the average (or something like a gaussian blur): use conv2, as described in the answer you linked. Read the document...

How do you average each pixel in an image with a 9x9 square?

If you want the average (or something like a gaussian blur): use conv2, as described in the answer you linked. Read the document...

4 dagen ago | 0

| accepted

Answered

Running same program is giving different plot

Clear all should only exist exactly once in your entire code base. Replace it with clear or clearvars. If you want to have re...

Running same program is giving different plot

Clear all should only exist exactly once in your entire code base. Replace it with clear or clearvars. If you want to have re...

4 dagen ago | 0

| accepted

Answered

Reshaping a Char Array

This should do it: A = ['12';'12';'12';'12';'12';'12';'12';'12';'34';'34';'34';'34';'34';'34';'34';'34';'56';'56';'56';'56';'56...

Reshaping a Char Array

This should do it: A = ['12';'12';'12';'12';'12';'12';'12';'12';'34';'34';'34';'34';'34';'34';'34';'34';'56';'56';'56';'56';'56...

5 dagen ago | 1

| accepted

Answered

How to draw a inscribed circle having maximum radius inside the binary image. I have already identified the centroid of the object.

If you invert your image, you can use bwdist to find the point furthest from the edge. That distance is by default the radius of...

How to draw a inscribed circle having maximum radius inside the binary image. I have already identified the centroid of the object.

If you invert your image, you can use bwdist to find the point furthest from the edge. That distance is by default the radius of...

5 dagen ago | 0

Answered

For Loop. My goal is for my code to recognize if the user inputs an empty 'grade' and then to loop back into itself until the user enters 10 grade values individually.

I would suggest using a cell array initially, which you can convert to a normal array after the loop. That way you can use the i...

For Loop. My goal is for my code to recognize if the user inputs an empty 'grade' and then to loop back into itself until the user enters 10 grade values individually.

I would suggest using a cell array initially, which you can convert to a normal array after the loop. That way you can use the i...

6 dagen ago | 0

Answered

How do I store values from a while loop and plot the values in fonction of the number of iteration?

Indices in Matlab need to be positive integers. You should create a separate time vector. And don't forget to index Temp, other...

How do I store values from a while loop and plot the values in fonction of the number of iteration?

Indices in Matlab need to be positive integers. You should create a separate time vector. And don't forget to index Temp, other...

6 dagen ago | 0

| accepted

Answered

minify Matlab code (minimize number of characters)

It took some time, but here is my solution. Strip all comments and line continuations. Separate the code and the embeded chars...

minify Matlab code (minimize number of characters)

It took some time, but here is my solution. Strip all comments and line continuations. Separate the code and the embeded chars...

7 dagen ago | 0

Solved

Pizza!

Given a circular pizza with radius _z_ and thickness _a_, return the pizza's volume. [ _z_ is first input argument.] Non-scor...

8 dagen ago

Answered

How can I create a Matrix according to a formula?

Learn about meshgrid and/or ndgrid. (assuming you mean D(i,j) instead of D(ij))

How can I create a Matrix according to a formula?

Learn about meshgrid and/or ndgrid. (assuming you mean D(i,j) instead of D(ij))

9 dagen ago | 0

Answered

I need two outputs and I'm only getting one, please help me

You didn't actually assign any outputs, so Matlab only stores the first one in ans. If you want to actually store variables you ...

I need two outputs and I'm only getting one, please help me

You didn't actually assign any outputs, so Matlab only stores the first one in ans. If you want to actually store variables you ...

9 dagen ago | 0

Answered

What is the probability that their children can travel in a straight line between any two points without leaving the boundary? In other words, what is the probability that the boundary is a convex quadrilateral?

If you want to do a Monte-Carlo-style simulation, I would suggest using rand to generate the coordinates. I would suggest puttin...

What is the probability that their children can travel in a straight line between any two points without leaving the boundary? In other words, what is the probability that the boundary is a convex quadrilateral?

If you want to do a Monte-Carlo-style simulation, I would suggest using rand to generate the coordinates. I would suggest puttin...

9 dagen ago | 0

Answered

Annually averaging of a 4D matrix

You are using the color operator incorrectly. 1:2:3 doesn't mean [1 2 3], but [1 3]. If your syntax does indeed work for you, t...

Annually averaging of a 4D matrix

You are using the color operator incorrectly. 1:2:3 doesn't mean [1 2 3], but [1 3]. If your syntax does indeed work for you, t...

9 dagen ago | 0

| accepted

Answered

finding a phrase in a modularized code with over 1000 functions

You can use Matlab tools, as Ameer describes, but you can also use external software. I personally find the performance of searc...

finding a phrase in a modularized code with over 1000 functions

You can use Matlab tools, as Ameer describes, but you can also use external software. I personally find the performance of searc...

9 dagen ago | 0

Answered

How to plot data with >2 dimensions?

Apart from plot3 (as Alan suggested), you may also consider using subplot to divide the different scenarios and using hold to pl...

How to plot data with >2 dimensions?

Apart from plot3 (as Alan suggested), you may also consider using subplot to divide the different scenarios and using hold to pl...

9 dagen ago | 0

Question

minify Matlab code (minimize number of characters)

I would like to find a way that reduces the footprint of a function as much as possible. The actual functionality should not cha...

12 dagen ago | 2 answers | 1

Answered

How can I get my figure window to pop up with the animation playing when I execute the code?

You probably mean you want to make the figure the current figure and bring it to the foreground. If so: figure(1) cla;%i...

How can I get my figure window to pop up with the animation playing when I execute the code?

You probably mean you want to make the figure the current figure and bring it to the foreground. If so: figure(1) cla;%i...

12 dagen ago | 0

| accepted

Answered

Find the element that is a sqrt of another element in the same array function?

To compare many elements to each other I would recommend the ismember function.

Find the element that is a sqrt of another element in the same array function?

To compare many elements to each other I would recommend the ismember function.

13 dagen ago | 0

Answered

Refresh annotate on figure in loop

Create the annotation object once, and update the String property inside your loop. I would suggest drawnow to trigger the upda...

Refresh annotate on figure in loop

Create the annotation object once, and update the String property inside your loop. I would suggest drawnow to trigger the upda...

13 dagen ago | 0

Answered

Locate elements of a vector inside a meshgrid

I would suggest using ismembertol, or consider functions like normxcorr2 from the image processing toolbox.

Locate elements of a vector inside a meshgrid

I would suggest using ismembertol, or consider functions like normxcorr2 from the image processing toolbox.

15 dagen ago | 0

Answered

How do I read this file and extract the data to plot and average it

Good call on not using str2num, you should consider using str2double (or textscan or datetime) instead: [date,value]=read_json_...

How do I read this file and extract the data to plot and average it

Good call on not using str2num, you should consider using str2double (or textscan or datetime) instead: [date,value]=read_json_...

15 dagen ago | 0

Answered

clean all paths except factory ones (toolboxes)

Appart from using restoredefaultpath, you might consider borrowing code from toggleToolbox to toggle the states of your path.

clean all paths except factory ones (toolboxes)

Appart from using restoredefaultpath, you might consider borrowing code from toggleToolbox to toggle the states of your path.

15 dagen ago | 0

Answered

How do I create an exact looping code for my following problem?

You are remove all elements from phi, so your second iteration does what you ask: nothing. Please learn how to use the debuggin...

How do I create an exact looping code for my following problem?

You are remove all elements from phi, so your second iteration does what you ask: nothing. Please learn how to use the debuggin...

16 dagen ago | 0

Answered

Crop a part of binary image

My suggestion would be to determine the number of white pixels in each column, and use an automatic way to determine a threshold...

Crop a part of binary image

My suggestion would be to determine the number of white pixels in each column, and use an automatic way to determine a threshold...

16 dagen ago | 0

| accepted