Community Profile

# Rik

##### Last seen: Today
2.159 total contributions since 2017

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.

View details...

Contributions in
View by

reshape vector to matrix
[d(1:(end-1)).' d(2:end).']

ein Tag ago | 0

In case you just want to know how to create a recursive function at all: function n=I_call_myself(n) disp(n) if n>0 n=I_...

2 Tage ago | 0

Need help making my riddles work
You should use the debugger to go through your code line by line and see what is happening with your variables. You are overwri...

2 Tage ago | 0

Anonymous Function soustraction problem with a parameter
You were not actually evaluating the function for values of f; you were entering the anonymous function as a char array. %verif...

3 Tage ago | 0

| accepted

Evaluate function over a mesh grid (without for loops)
You have to vectorize the function and split it into two steps: Jfun = @(x,y) (17*x.^2)/2 - 14*x.*y - 40*x + 19*y.^2 - 20*y; u...

4 Tage ago | 0

| accepted

plot bar with two colors
If you insist on separate bar objects you can use the first part, if not, you can use the second part figure(2),clf(2)%ensure a...

4 Tage ago | 0

Processing txt multiple files in a folder and saving them using the original name but different format
Something like this should work: %replace this: filename = files(i).name; addpath('sorted_csv') dlmwrite(filenam...

4 Tage ago | 0

| accepted

save an algorithm and call it
Store this in thomas.m function z=thomas(Ac,b,p_minus_2) %solving linear system with Thomas algorithm % % More explanation a...

5 Tage ago | 0

| accepted

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

7 Tage ago | 0

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.

7 Tage ago | 0

| accepted

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(...

7 Tage ago | 1

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...

7 Tage ago | 0

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...

7 Tage ago | 2

| accepted

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...

7 Tage ago | 0

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...

8 Tage ago | 1

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...

9 Tage ago | 0

| accepted

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...

9 Tage ago | 0

| accepted

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...

10 Tage ago | 1

| accepted

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...

10 Tage ago | 0

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...

11 Tage ago | 0

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...

11 Tage ago | 0

| accepted

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...

12 Tage 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...

13 Tage ago

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))

14 Tage ago | 0

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

14 Tage ago | 0

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...

14 Tage ago | 0

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...

14 Tage ago | 0

| accepted

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...

14 Tage ago | 0

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...

14 Tage 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...

17 Tage ago | 2 answers | 2