Community Profile

photo

Jos (10584)


1.446 total contributions since 2006

Professional Interests: neuroscience, physics, mathematics

Contact

Jos (10584)'s Badges

  • Thankful Level 2
  • Revival Level 1
  • 12 Month Streak
  • Guiding Light
  • Knowledgeable Level 4
  • First Answer
  • Scavenger Finisher
  • Speed Demon
  • Solver

View details...

Contributions in
View by

Answered
How to find first '1' in every row
Not better than using max (for this type of input), but just to show you an alternative: A = [ 0 0 0 0 0 0 1 1 1 1 0 0; 0 0 0 ...

circa 16 ore ago | 1

Answered
How writing code sum 1+2+3+4+...+n
or know your math classics ... n = 120345428372 s = n*(n+1)/2 % sum(1:n) will fail!

3 giorni ago | 0

Answered
How to output random number each time a for loop repeats?
You can use an extra variable to keep track of the letters that were guessed correctly. InputString = 'hello' N = numel(InputS...

4 giorni ago | 0

| accepted

Answered
a question on for loop statement
This is filtering. T=10; % smaller example k=0.1; u=rand(T,1); % your loop -> a a = zeros(T,1); a(1) =u(1)+ k*0.01; ...

5 giorni ago | 3

Answered
Select random data from a matrix and replace it
Here is another, indexing, approach: A = randi(2, 6, 8)-1 % random 0/1 array M = 3 % max number of 1's per column szA = s...

5 giorni ago | 1

Answered
Create a Cell Array of Vectors populated with ones
repmat also works for cell arrays C = repmat({nan(1, 200)}, 10, 3)

6 giorni ago | 1

| accepted

Answered
filling a matrix with a loop
% clever indexing trick A= [1 1 0 1] N = 10 ; % smaller example! 400 in your case X = triu(toeplitz(1:N)) ; X(X > numel(A)) ...

7 giorni ago | 0

Submitted


PERMPOS
all possible ordered permutations of M values in N positions

7 giorni ago | 6 downloads |

Thumbnail

Answered
Concatenate Structures: select structures only if not empty.
This clearly shows the drawback of naming your variables dynamically, like A1, A2, A3, A4. If you change, for instance, the way ...

17 giorni ago | 1

| accepted

Answered
How to find slope of this line
You can create a complete list of x,y pairs by expanding x to the size of y. Looking at your code, I think a single element of x...

18 giorni ago | 0

| accepted

Answered
Dissect a String and create list with Matlab
A = "black || white || pink || yellow" B = split(erase(A,'|')).'

19 giorni ago | 0

| accepted

Answered
Removing NaNs from a struct
TF = arrayfun(@(k) isnan(AllData.Passive(k).T(1)), 1:numel(AllData.Passive)) AllData.Passive(TF) = []

20 giorni ago | 1

Answered
Changing Indexing Order in matrix raws
Your question is a little confusing, but here is my take on it: A1 = [0 0 0 0 0 0 0 0 0 1 2 3 4 5] A2 = [12 11 14 5 1] out([n...

20 giorni ago | 1

Answered
Repeating a function n times with different values from a vector
If you organize the input differently, this is not so difficult x = [1 2 ; 3 4 ; 5 6] ; % organized into rows N = size(x,1) ; ...

20 giorni ago | 1

| accepted

Answered
i have a question that works backwards
What about % X is known F = X D = ones(size(F)) % F ./ (D.^5) equals X or is this to simply thought by me ;-)

22 giorni ago | 0

Submitted


nchoosekcom
NCHOOSEK with its complementary combinations

22 giorni ago | 1 download |

Thumbnail

Answered
How can i use nchoosek to output both the k combinations and the remaining combinations?
The remaining values can simply be obtained using nchoosek(1:n, n-k), you just have to flip the order of the output :-) n = 7 ...

22 giorni ago | 2

Answered
How to create a matrix from for loop result?
D = [170, -80, -30, 0, -50, -30, 20, -60, 100, -60 -20]; Iplus=find(D>0); A = [] ; % initialize for i=1:size(Iplus,...

23 giorni ago | 0

| accepted

Answered
How to select desired row
ix = [0:224:81563]' + 1:112 ; % calculate row indices ix(ix>size(A,1)) = [] % remove row indices that are too larger A2 = A(ix...

26 giorni ago | 1

| accepted

Submitted


permsk
All permutations of K elements from an array (set)

29 giorni ago | 3 downloads |

Thumbnail

Answered
How to change character in multiple cells in to number 0 and 1?
Sex = {'F','M','F','F','M','M','F'} [~, SexNum] = ismember(Sex, {'F','M'}) SexNum = SexNum - 1 % 1 = 'M', 0 = 'F', -1 = other ...

circa un mese ago | 0

| accepted

Answered
load files whith a previus specified name
Didn't you just make a simple typo? % Aplha vs Alpha % | |

circa un mese ago | 1

| accepted

Answered
Using numpad 8 2 6 4 as North South East West
Perphaps my getkey function may be of use to you: https://www.mathworks.com/matlabcentral/fileexchange/7465-getkey

circa un mese ago | 0

Answered
I keep getting the error message that vectors must be the same length in the plot command
So, apparently the two vectors are not of the same length. You really should learn how to debug your own code. Set a breakpoint ...

circa 2 mesi ago | 1

Answered
Select random elements from three consecutive columns in a big matrix?
M = magic(5) % input data N = 4 % number of selections nC = 3 % number of consecutive columns % engine szM = size(M) r...

circa 2 mesi ago | 0

Answered
select random row inside the cell
You want the row, or the row number to be returned? A={[1,4,6;6,5,4;1,2,4],[1,3;5,4],[1,2;1,7;6,8]} rownumber = cellfun(@(c)...

circa 2 mesi ago | 0

| accepted

Answered
Writing a Matrix 6x6 in one line
help reshape

circa 2 mesi ago | 0

Answered
Vectorizing nested for loops
A = magic(5) d = squareform(pdist(transpose(A))) % transpose to obtain vecnorm between columns pdist and squareform are part ...

circa 2 mesi ago | 1

| accepted

Answered
how to find the element which is greater than or equal to its row and smaller or equal to its column in a matrix
function out = saddle(M) [r, c] = ind2sub(size(M), 1:numel(M)) ; tf = arrayfun(@(r, c) all(M(r, c) >= A(:, c)) && all(M(r, c) ...

circa 2 mesi ago | 0

Answered
omit same element inside cell
You can convert the elements of each cell to a char array and apply unique on that cell array of chars. A = {[1,2,3,4],[4,2,3],...

circa 2 mesi ago | 1

Load more