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

más de 8 años hace | 0

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

más de 8 años hace | 2

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

más de 8 años hace | 0

| aceptada

Enviada


randpermmat(N, M)
Random permutation matrix

más de 8 años hace | 3 descargas |

0.0 / 5
Thumbnail

Respondida
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)

más de 8 años hace | 1

Respondida
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 ;...

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 0

Respondida
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: ...

más de 8 años hace | 0

Respondida
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:/...

más de 8 años hace | 3

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

más de 8 años hace | 0

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

más de 8 años hace | 1

| aceptada

Respondida
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'...

más de 8 años hace | 1

| aceptada

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

más de 8 años hace | 0

Respondida
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?

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 1

| aceptada

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

más de 8 años hace | 0

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

más de 8 años hace | 0

Respondida
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 :)...

más de 8 años hace | 1

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

más de 8 años hace | 0

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

más de 8 años hace | 2

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

más de 8 años hace | 0

| aceptada

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

más de 8 años hace | 3

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

más de 8 años hace | 0

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

más de 8 años hace | 2

| aceptada

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

más de 8 años hace | 1

| aceptada

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

más de 8 años hace | 0

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

más de 8 años hace | 0

| aceptada

Respondida
how to delete this error?
or even shorter y = ~x

más de 8 años hace | 2

Respondida
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.' ...

más de 8 años hace | 0

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

más de 8 años hace | 1

| aceptada

Cargar más