Réponse apportée
How to repeat letter presented two steps before?
This seems to be some kind of homework assignment (which is fine!) so I will just give you some thoughts: # You have a set X ...

environ 8 ans il y a | 0

Réponse apportée
How do I split a folder with images into two folders with images using MATLAB?
# retrieve all filenames using *dir* # create a random logical vector with 70% true, e.g. *tf = randperm(N) > (0.70 *N)*, where...

environ 8 ans il y a | 2

Réponse apportée
I have a vector that is the combination of 2 data sets alternating every n data points. How do I separate these into their own vectors?
You can use logical indexing to separate the two sets, and NaNs to separate the plotted segments: % data data = cumsum(r...

environ 8 ans il y a | 0

| A accepté

A soumis


randpermmat(N, M)
Random permutation matrix

environ 8 ans il y a | 1 téléchargement |

0.0 / 5
Thumbnail

Réponse apportée
how to create a square matrix with unique real values?
A very simple one-liner will do the trick: N = 10 ; [~, A] = sort(rand(N), 2)

environ 8 ans il y a | 1

Réponse apportée
Can I save my outputs in a way to use them as my inputs for the next run?
Assuming the function above in a m-file, called _MyFunction.m_ function [C,D] = MyFunction (A,B) C = A*B ; D = A+B ;...

environ 8 ans il y a | 0

| A accepté

Réponse apportée
Index same value numbers in array
I offer you my function *runindex* which does exactly this, fast and vectorised! A = [1 1 1 5 5 8 9 9 9 9 10 11] B = run...

environ 8 ans il y a | 0

Réponse apportée
In a Matlab plot(x,y) having both negative and positive 'y' values, how to display the xtick labels at zero(0) line too
The word too implies showing the tick labels twice ... This just repositions the axis, which is what you're after, I think: ...

environ 8 ans il y a | 0

Réponse apportée
second condition never gets executed - elseif (temp == 13.2) tried to run in 13b, 15b online edittors as well, any explanations or its a bug?
Welcome to the world of computers where it is tricky to compare floating point numbers. Take a look at the answer here: <https:/...

environ 8 ans il y a | 3

Réponse apportée
How to effectively run loops and save time in computation? I have a matrix of size 'm' and run five loops from 1 to m. The logic is explained below. How to optimize the code and save time of calculation.
A few observations: # you should pre-allocate x, y and output before the loops # H(i,k) + H(j,k) equals H(j,k)+H(i,k), so yo...

environ 8 ans il y a | 0

Réponse apportée
How to remove certain elements of an array but keep original indices of elements that are kept
Time toe learning about logical indexing! x = [3 -1 -1 5 -1 -1 -1 8 2 -1 -1 9] tf = x ~= -1 idx = find(tf) y = x(t...

environ 8 ans il y a | 1

| A accepté

Réponse apportée
is there any way that can speedup the process of following code... A and B are 50000x20 matrices..?
Your looking for corresponding rows in A and B. *intersect* might help you [~,ia,ib] = intersect(A(:,1:7), B(:,1:7), 'rows'...

environ 8 ans il y a | 1

| A accepté

Réponse apportée
How do I ensure random generates different samples each trial?
Executing rand (or random or randi) will return new random numbers, uncorrelated to previously retrieved numbers (unless you see...

environ 8 ans il y a | 0

Réponse apportée
How to normalize the sine wave for the given code below?
y_normalised = 2*(y - mean(y)) ./ range(y) ; or set the amplitude to 1 instead of t when you create the sinewave?

environ 8 ans il y a | 0

| A accepté

Réponse apportée
How do I fit an exponential equation to raw data
This should get you started: % some data x = 1:20 ; y = exp(-10 ./ (x .^ 1.1)) ; yr = y + randn(size(y))/10 ; % ad...

environ 8 ans il y a | 1

| A accepté

Réponse apportée
programming the number of steps till every element of a set appears
What have you tried so far, perhaps in writing some pseudocode, or making a flowchart? *randi* and *while* are functions that...

environ 8 ans il y a | 0

Réponse apportée
All combinations from a set of rows without repetition of elements
You might be interested in a faster alternative for nchoosek(n,k) when k equals 2: <https://uk.mathworks.com/matlabcentral/fi...

environ 8 ans il y a | 0

Réponse apportée
remove pixels with certain rgb values
Is I really a 3D array or is the third dimension just 1? Simply take a look at the value of rgb, after the size(I) command :)...

environ 8 ans il y a | 1

Réponse apportée
Concentric circles with different colors
You can specify a colormap beforehand: R = 30:-5:5 ; % radii N = numel(R) ; % Cmap = parula(N) ; % one of the many a...

environ 8 ans il y a | 0

Réponse apportée
How to calculate euclidean distance between two feature vectors
Take a look at * *norm** EuclideanDistance = norm(vec2-vec1, 2)

environ 8 ans il y a | 2

Réponse apportée
How can I save my plots with file names from a string in my loop?
Add '.fig' to each filename saveas(h, [filenames{k+3} '.fig'], 'fig') Also try to reconsider your approach when you add ...

environ 8 ans il y a | 0

| A accepté

Réponse apportée
How to get cumsum to work on consecutive values and restart if there is a 0 value?
Here is a rather easy approach: G = [ 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 1 0 NaN 0 NaN 0 9 9 9 9] % data ix = cumsum([true di...

environ 8 ans il y a | 3

Réponse apportée
change the dimension of multidimensional matrix
Maybe you're looking fo cell arrays, in which each cell can hold a vector of different lengths? As an example: Nrows = 1...

environ 8 ans il y a | 0

Réponse apportée
How to add plot titles in a for loop
You use the wrong format identier (%d) in sprintf,, which should be %s: X = 'Jasper' sprintf('Hello %s!', X) (and you...

environ 8 ans il y a | 2

| A accepté

Réponse apportée
Sample of sine wave
Something along these lines? t = linspace(0,2*pi,1000) ; y = 100 * sin(2*pi*1.8*t) ; s = sort(randperm(numel(t),1...

environ 8 ans il y a | 1

| A accepté

Réponse apportée
How to add or multiply two different size of array using the loop iteration process?
a = [1 2 3 4 5 6 7 8 9 ] b = [1 2 3 4] % Generic case: numel(a) is not a multiple of numel(b) nb = num...

environ 8 ans il y a | 0

Réponse apportée
How to generate a random noise with increasing amplitude?
Something like this? N = 1000 ; t = linspace(0,5,N) ; % seconds y = 10*sin(2*pi*0.5*t) ; % signal MaxNoise = 4...

environ 8 ans il y a | 0

| A accepté

Réponse apportée
how to delete this error?
or even shorter y = ~x

environ 8 ans il y a | 2

Réponse apportée
move all zeros to the right in a matrix
Here is one way: % data X = [1 2 3 0 4 ; 1 0 0 0 2 ; 1 0 2 3 4 ; 1 2 3 0 0 ; 0 0 0 0 1] % engine X = X.' ...

environ 8 ans il y a | 0

Réponse apportée
Sum if multiple conditions satisfied across different arrays
% data S = randi([0 1],4,10) % state matrix adj = [0 1 1 1 ; 1 0 0 1 ; 1 0 0 1 ; 1 1 1 0] % adjacency matrix (symmetric...

environ 8 ans il y a | 1

| A accepté

Charger plus