Community Profile

photo

Jos (10584)


1 513 total contributions since 2006

I have been using Matlab since version 4 (1999 or so) and still prefer it over all other software tools available for data manipulation :-)

My professional interests: neuroscience (motor control & eye movements), cognitive psychology physics, mathematics, teaching

"The most important part of programming is writing the comments!"

Contact

Jos (10584)'s Badges

  • Editor's Pick
  • First Review
  • 5-Star Galaxy Level 5
  • First Submission
  • 24 Month Streak
  • Thankful Level 2
  • Revival Level 1
  • Guiding Light
  • Knowledgeable Level 4
  • First Answer
  • Scavenger Finisher
  • Speed Demon
  • Solver

View details...

Contributions in
View by

Answered
Could anyone suggest me is there any way of choosing maximum and minimum values together
Here is a nice trick that also allows you to combine functions in a single call, which also can return the other outputs of thes...

2 dagar ago | 1

Answered
How to have a multiple choice questionnaire that will ask the next question depending on the answer?
Take a look at all the dialog functions in matlab like questdlg, listdlg etc. Start however drawing a graph of all the question...

2 dagar ago | 0

Answered
how to find nearest date corresponding value ?
Does this return what you want? R = AOD_440(closestIndex, [1 2]) % select first (date?) and second (values?) columns

2 dagar ago | 0

| accepted

Answered
Plotting an Archimedean Spiral
In the computation of x and y you wrongly multiply b with Th. You should multipy by Th / (2*pi): r = 12.5; %outer radius a =...

3 dagar ago | 0

| accepted

Answered
replace duplicate value by 0 in matrix or vector
% for small vectors: b = [1 2 1 3 2 1 4 2] b(sum(triu(b == b')) > 1) = 0

4 dagar ago | 0

Answered
concatenate arrays after performing addition
A little simpler than all those permutes and reshapes: A = [1 2 3 ; 4 5 6 ; 7 8 9] ; B = [2 3 4 5] ; C = repmat(A, numel(B), ...

4 dagar ago | 0

Answered
Alternation without for loop
% a sorting trick A = [1 2 3 4 5 6 7 8 9 10] B = [0.5 0.2 0.4 0.8 0.9] C = [A B] ; [~,ix] = sort([1:numel(A) 1:numel(B)]) C...

4 dagar ago | 0

Answered
Matching closest values to each other
For larger vectors, where BSXFUN will require a lot of memory, function NEARESTPOINT might be useful A = rand(1000000,1) ; B = ...

4 dagar ago | 1

| accepted

Answered
Sort Descend Scientific Notation Error
You misuse the sort command. Simply: sortedu = sort(u ,'descend') would do :-) Moreover, if you remove the semicolons, you ...

5 dagar ago | 0

Answered
making an array to simulate states of a paramagnet with values of -1,+1.
Create a random vector with two values and map those to -1 and 1. An easy solution (with n=10): x = 2 * randi([0 1], 1, 10) - 1...

7 dagar ago | 0

Answered
for loop that changes specific letters to numbers
Another option: str = 'apple'; TF1 = any(lower(str) ~= 'aeiou'.')

15 dagar ago | 2

Answered
Finding Min Value in array with changing condition
tf = a == 1 % create a logical array temp = cost(tf) % logical indexing to retrieve certain values mincost = min(t...

20 dagar ago | 0

Answered
How to genetate random number under constraint
Brute force attempt: N = 20 ; xyRange = [100 1900] ; minimumDistance = 200 ; attempt_counter = 1 ; Distances = 0 ; while ...

23 dagar ago | 0

Answered
Add an element to a 3D array
To concatenate two arrays A and B in the third dimension, use cat cat(3, A, B) Note that all the other dimensions of A and B s...

23 dagar ago | 0

Answered
To concatenate rows in matrix within for loop based on if else statement
This code is weird. In each iteration of "index" you fill either a matrix temp or a matrix temp_noise with m rows of values. T...

25 dagar ago | 1

Answered
To generate matrix from an array
More general, using indexing: A = [1 22 3 44 55 666 7 888 9] n = 2 B = A(((1:numel(A)-n).' + (0:n)))

25 dagar ago | 0

Answered
How to exclude a line in legend?
Get the handles of the lines and create a legend only for the desired handles. It is all in the documentation :-) doc legend

25 dagar ago | 0

| accepted

Answered
Shifting a signal to the right or left
x = 1:5 shift = 3 x = circshift(x,shift) N = numel(x) ix = (1:N) - shift tf = ix < 1 | ix > N x(tf) = 0

29 dagar ago | 1

Answered
How to make a matrix with the entries being the number of even indices of that entry?
help meshgrid help rem

ungefär en månad ago | 0

Answered
Could anyone help me to solve the issue.
ix = find(abs(diff(A)) < YourThreshold, 1, 'first') % maybe you want to add + 1 B(ix:end) = B(ix)

ungefär en månad ago | 0

Answered
How can I keep the highest N% values of a data set?
Use MAXK: Y = maxk(X, ceil(N * numel(X) / 100))

ungefär en månad ago | 1

| accepted

Answered
Function calculating distance between pixels in 1x1x3 arrays
The function you found is rather badly coded ... Another expression for "calculating a distance" is "taking the norm". Matlab h...

ungefär en månad ago | 1

| accepted

Answered
how to extend the writing of the comments ?
You can set this in the preferences for the editor/debugger. Look for the Right-hand text limit.

ungefär en månad ago | 1

Answered
Best way to calculate the determinants of a series of matrices?
Elaborating on the answers using arrayfun, you can avoid the multiple squeeze operations by permuting the dimension order first:...

ungefär en månad ago | 0

Answered
Fill an array with different size vectors
A=[1,2,3,4]; B=[5,6]; C=[7,8,9]; [ARRAY, tf] = padcat(A,B,C) % pad with NaNs ARRAY(~tf) = 0 % replace those NaNs with zeros ...

ungefär en månad ago | 0

Answered
add new rows to a Matrix
Despite its simple appearance, this is not a trivial task, for which I created my insertrows function A = randperm(10).' B = i...

ungefär 2 månader ago | 0

Answered
reduce rows of a due to b
You can simply use setdiff with the rows option ... c = setdiff(a,b,'rows')

ungefär 2 månader ago | 0

Answered
exclude values of a matrix inside a for loop
you can replace the outliers by NaN before the loop and then use nanmax and nansum in your calculations

ungefär 2 månader ago | 0

| accepted

Answered
Find unique or duplicate cells in cell array of chars
A = {{'A', 'B', 'C'}, {'C', 'D', 'E'}, {'A', 'B', 'C'}, {'C', 'B', 'A'}} N = arrayfun(@(k) sum(arrayfun(@(j) isequal(A{k}, A{j}...

ungefär 2 månader ago | 1

| accepted

Answered
How to compare two vector with different dimension
I assume the elements of x and y are linked? Why is the first element of (x2,y2) than not in the list of coordinaties (x1,y1)? I...

ungefär 2 månader ago | 0

Load more