Community Profile

photo

Rik


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

Contact

Rik's Badges

  • 24 Month Streak
  • Revival Level 3
  • Guiding Light
  • Thankful Level 2
  • Knowledgeable Level 4
  • First Answer
  • Solver

View details...

Contributions in
View by

Answered
How to horizontally align multiple lines ylabel
(untested idea) You can trick the alignment by making sure the square bracket part is the middle line. To achieve this you ca...

alrededor de 4 horas ago | 0

Answered
Sort a structure by the date field
Don't concatenate to a cell, but to an array: examplestruct = struct; for i = 1:5 examplestruct(i).data = rand(1,10); en...

alrededor de 19 horas ago | 0

| accepted

Answered
How can I find the maximum value and time array in MATLAB?
Use the second output of max: a = [1 2 ; 4 5 ; 7 8 ; 6 11 ; 4 3 ]; [val,ind]=max(a(:,2)); time_val=a(ind,1);

alrededor de 23 horas ago | 0

Answered
plotting a function from an m file
You forgot to add 100 in your actual code: plot(x,f(x,100)) You should avoid using sum as a variable name, because it sh...

1 día ago | 0

Answered
Saving structure as a .mat file with matrices, strings and numbers
There are two issues here. If you read the doc it specifies that the struct must be scalar (each field is allowed to be any type...

1 día ago | 0

Answered
How to increment a subscript in Matlab using the ylabel function?
The syntax you are attempting to use would work if you're using strings. However, you are using char arrays. Either switch to a ...

1 día ago | 0

| accepted

Answered
How to code fprintf on multiple lines ?
As far as I'm aware this should work with strings as well, but I frequently use a setup like this with a char array instead. So ...

2 días ago | 1

| accepted

Answered
Insert PNG image into normal image
If you want to prevent overwriting the underlying image for some pixels, you can use a logical mask to only overwrite some pixel...

2 días ago | 0

Answered
Write data to text file
This is probably due to Matlab being column-based, instead of row-based. This may result in counterintuitive results if you ente...

3 días ago | 1

| accepted

Answered
Cell to matrix average
Something like this should work for you: %generate some example data data=cell(93,1); for n=1:93 data{n}=rand(45,147,19)...

3 días ago | 0

Answered
How do you use ls to change your directory in Matlab?
The homework is either badly designed, or is attempting to teach you why you shouldn't use it. You shouldn't change your curren...

3 días ago | 0

Answered
Standard Deviation of 3D matrix with NaN elements
This syntax should work for most releases: sdev=std(m(:),'omitnan');

3 días ago | 0

Answered
Picking files according to file names
Use the dir function to generate a list of files, then parse the file names in a loop and continue to read the relevant files.

4 días ago | 0

| accepted

Answered
Finding consecutive data with non zero in array
I used the mfile version of Jan's FEX submission RunLength, because I can't get my compiler to work right now. With the runlegth...

4 días ago | 0

Answered
randomly divide vector into 2 parts.
I don't fully understand every step of your code, so I rewrote it: index_rating=rand(100000,5);%generate example data training...

5 días ago | 0

| accepted

Answered
imread not working for gif problem
It took some digging with the debugger, but with enough breakpoints I was able to track down the cause. Your calls are failing b...

5 días ago | 2

| accepted

Answered
write a range on the y-axis
You can modify the XTickLabels property to display any char array. figure(1),clf(1)%only use clf during debugging ax=axes; pl...

5 días ago | 0

| accepted

Answered
How can I run a Matlab script at the same time everyday?
It is probably easiest to use the options your OS provides and run a headless instance of Matlab. On Windows you can use the tas...

8 días ago | 0

Answered
Changing data from long form to short form
You can use the participant ID and trial ID as the indices and either use accumarray or sub2ind to fill the matrix with the valu...

8 días ago | 1

Answered
How to count the number of voxels of another color
Similar to how you would do that for 2D: IM=randi(255,[512 512 400]); count=sum(IM==200,'all'); %if your release doesn't ha...

9 días ago | 0

| accepted

Answered
Save data from MatLab GUI to struct .mat file
You should always load to a struct. That makes it clear where variables come from. Then it is also easier to extend the struct i...

9 días ago | 1

| accepted

Answered
How can I base my legend on the markers I defined in my plot?
The best solution is to set the DisplayName property when calling plot, and/or use an array of handles to create the legend. See...

9 días ago | 0

| accepted

Answered
Legend repeating same color
Set the DisplayName property when calling plot, or use the output from plot to build your legend with specific handles. x=linsp...

9 días ago | 0

| accepted

Answered
write and read the same image but they are different
You should read the documentation of the functions you're using if you want to understand them. Matlab has excellent documentati...

9 días ago | 0

Answered
Make matlab use a function from a certain toolbox
You have assigned something to a variable named dist. That will shadow all functions. The solution is not to use dist as a varia...

10 días ago | 0

| accepted

Answered
Comparing 2 lists and assign a value
If you can make two arrays, you can use the ismember function, which should work well for large arrays as well.

11 días ago | 0

Answered
How do I end a program when a condition is met using only if-else-elseif statements?
Something like this will work (edit to add nesting): function out=MyFunction(in) if in<1 if in==0.5 %do somethin...

11 días ago | 0

| accepted

Answered
Why won't MatLab properly download onto my windows laptop?
If you go to your account (this link should get you there) you can click on your license number. Then go the 'Install and Activa...

12 días ago | 0

Answered
Custom GUI: Check for updates
You could probably have a function check your website at most once a week by calling your update function when starting some spe...

13 días ago | 1

| accepted

Answered
HOW Calculate the distance of points form one center in 2-D space and display output in a distance matrix?
This should do the trick: X=2*(rand(5,5)-0.5); Y=2*(rand(5,5)-0.5); x=0.3;y=0.3; d=point2pointcloud(X,Y,x,y) function d=p...

13 días ago | 1

| accepted

Load more