Réponse apportée
Using range in a vector
I am a little confused by your problem, but here are my thoughts. You might want to use the function ANY, or its sibling ALL, or...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
There is an error in exp function but it doesn't tell what the error is?
Use dbstop if error and inspect the contents of the variables! You'll see what is wrong :-)

presque 7 ans il y a | 0

Réponse apportée
Set up an OR argument for equation
Simpler, without an if-else: v = (xdot_1-xdot_2)).*(sign(x1-x2-gap)+1)/2; fp = (k_inp*(x1-x2-gap) + (v>0) * c_inp * (xdot_1-xd...

presque 7 ans il y a | 0

Réponse apportée
Set up an OR argument for equation
Can't you use logical indexing? A simplified example v = 10:20 q = v > 13 & v < 18 f(q) = 2*v(q) f(~q) = 30 + v(q)

presque 7 ans il y a | 1

Réponse apportée
How can I compare two measurements which are composed of matrices such as [0 1 0 0...]
You are looking for a measure of consistency between two measurements which are represented as binary vectors of the same length...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
How can I make each cell array consistent in length?
A final attempt to answer this question :-) C = {1:4 1:2 ; 1:5 1:6 ; 1 1:3} % a m-by-n cell array N = cellfun(@numel, C) % old...

presque 7 ans il y a | 4

| A accepté

Réponse apportée
split a diagonal matrix
Having a vector V with any number of elements, this does the job: V = [2 1 4] n = numel(V) ; M = zeros(n,n,n) ; M(linspace...

presque 7 ans il y a | 1

Réponse apportée
Extracting columns from a matrix, corresponding start and end times
The easiest approach is to create a for loop over the events Nevents = nume(EventTimes) R = zeros(64, 250, Nevents) % pre-allo...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
How can I make each cell array consistent in length?
C = {1:3 4 ; 5:9 10:12 ; 13:14 15} % a m-by-n cell array N = cellfun(@numel, C) maxN = max(N(:)) padfun = @(v) [v zeros(1, m...

presque 7 ans il y a | 1

Réponse apportée
replace values with nans
Take a look at logical indexing or the function ind2sub M = randi(10,8,6) % use indices of elements for which condition is tru...

presque 7 ans il y a | 0

Réponse apportée
Rearranging Array Rows into Multiple Blocks while Maintaining the Old Order
You should learn about indexing, one of the most essential aspects of Matlab: M = randi(4,10,5) ; M(:,1) = 1:size(M,1) % exampl...

presque 7 ans il y a | 1

| A accepté

Réponse apportée
Combine Array from different cell
This is called concatenation. See the documentation of the function CAT. Matlab allows you to concatenate a bunch of column vec...

presque 7 ans il y a | 0

Réponse apportée
how to make a column vector with evenly spaced entries with different coefficients
A simple one-liner: y = 3 ; k = 4 ; ycoeff(k:k:(k*k), 1) = (-k:-1)*y

presque 7 ans il y a | 0

Réponse apportée
Mathematical computation for ordering matrices
You can sort the values according to the second column using sortrows. Something along these lines might work for you: centers ...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
Concatenating a 3D matrix in the 3rd dimension when some cells are empty
B = cat(1,A{1,1,1,:}) % N-by-2 array

presque 7 ans il y a | 0

| A accepté

Réponse apportée
How can I make each cell array consistent in length?
If you make them the same length, you can also store them in a matrix. In that case, my PADCAT function is your friend :-) C = ...

presque 7 ans il y a | 1

Réponse apportée
Creating a table in matlab based on 2 variables and a for loop if statement.
This creates your table N = 11 ; % 10 timestamps time = 0:N-1 ; x = [4 3 1 4 2] ; y = [1 2 3 1 4] ; Z = repmat(y, N, 1) fo...

presque 7 ans il y a | 0

Réponse apportée
organising large sets of data into a irregular matrix
You can use cell arrays for this. A=[ 32 7.83425 32 8.0074 5 8.01005 5 8.0119 5 8.10775 19 8.1082 ...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
frequency of 2D matrix in 3D matrix
Convert the 3D N-by-M-by-Z matrix into a 2D Z-by-(N*M) matrix and use unique with the rows option on that. An example: M3D = ca...

presque 7 ans il y a | 0

Réponse apportée
How to generate data
I suggest you read parts of the starters manual and the help, and start exploring matlab :-) help linspace help colon x = 1:2...

presque 7 ans il y a | 0

Réponse apportée
Work with a data set to compute std
Step 1 - Write a function that calculates the correlation between two vectors X and Y with equal lengths, using the formula you ...

presque 7 ans il y a | 0

Réponse apportée
Finding the first and the last elements of consecutive numbers and combining them with a semi colon.
Using diff and logical indexing, this turns out to be quite simple: outliers = [1 2 3 4 5 10 20 21 22 23]; TF = diff(outliers)...

presque 7 ans il y a | 2

Réponse apportée
Split vector every time data changes from 2 to 1
Another approach: A = [1 2 1 1 2 1 2 2 1 1 1 2 2 2 1 1 1 2].' % data C = accumarray(cumsum([0 ; diff(A)==-1])+1, A, [], @(x) {...

presque 7 ans il y a | 1

Réponse apportée
Plotting a circle always around a moving point
Adapted from the help of animatedline: numpoints = 10000; x = linspace(0,4*pi,numpoints); y = sin(x); pc = [-.1 -.1 .2 ...

presque 7 ans il y a | 0

Réponse apportée
Issues with function ismember
Comparing floating point numbers is always tricky! Two number may look the same for you, but could still be slightly different f...

presque 7 ans il y a | 2

| A accepté

A soumis


randp
pseudorandom integers from a specified discrete distribution

presque 7 ans il y a | 1 téléchargement |

5.0 / 5
Thumbnail

Réponse apportée
How to find a combination like this
Computationally less efficient, and mathematically less beautiful as Walters' snippet, but more matlab-ish in style: N = 4 ; C...

presque 7 ans il y a | 0

Réponse apportée
How to compute fast?
Some suggestions: replace mean(A,B) by (A+B)/2 you can have j run from i to length(K1), since everything seems symmetric (unle...

presque 7 ans il y a | 0

| A accepté

Réponse apportée
How can I check if a specific set of numbers are present in my array?
I cannot resist to put the "simple" matlab version here. Note that this problem is closely related to Run-Length Encoding scheme...

presque 7 ans il y a | 3

A soumis


nchoose2
all combinations of two elements

presque 7 ans il y a | 3 téléchargements |

5.0 / 5
Thumbnail

Charger plus