Answered
What does "Line cannot be a child of line" mean?
semilogx is a command that plots values, it is not a transformation. The output is handle to a line object, not x-values that yo...

8 years ago | 0

| accepted

Answered
the loop question for the for loop. k=1:n
Your code is very unclear. Learn to use arrays and matrices. Rather than b1 = 2 ; b2 = 4 ; b3 = ... y1 = [1 2 3] ; y2 = ...

8 years ago | 1

Answered
How to create a matrix of values from an if statement?
The statement [randi(10), randi(10)] will change every time, moving the prey randomly around the field. Set the position of the ...

8 years ago | 0

Answered
How to print an array with same column starting locations?
Something like this? You can specify left alignment using the - sign fprintf([repmat('%-12.4f',1,size(A,2)) '\n'], A.') % n...

8 years ago | 0

| accepted

Answered
call on rows in order from arrays of different sizes
My idea: # Convert A and B into cell arrays (each row becomes a cell) # Merge into a single cell array # Sort based on fir...

8 years ago | 0

| accepted

Answered
Keeping rows of a matrix between two indicies.
I just want to point you to the following logic: if you start removing at the end, no indices will change: A(ix2:end,:) =...

8 years ago | 1

Answered
Shifting a signal to the right or left
x = 1:10 k = 3 xs = circshift(x,k)

8 years ago | 1

Answered
how can we randomly shuffle some columns of matrix in matlab?
Many options, here is a simple one using *randperm*: A = reshape(1:20,4,5) ; % example matrix c = [2 3] ; % columns to...

8 years ago | 1

Answered
how to apply 8x8 window to image of size 720x1280?
help blockproc (if you have the Image Processing Toolbox)

8 years ago | 0

Answered
I have a (1600X1)matrix. I want to creat a 3D matrix of dimension 417x425x1600 using repetition of the one array of (1600x1). How can I do that?
Many tricky roads to Rome: % simple exemplary data A = [10 11 12 13] ; M = 3 ; N = 5 ; % B will be a M-by-N-by-...

8 years ago | 0

Answered
How to map a value of a vector into column number of a matrix?
A fast and easy one-liner from the old days, when accumarray did not exist :) A = [2 ; 4 ; 5] B = full(sparse(A, 1:numel...

8 years ago | 0

Answered
How to shuffle the image pixels using combined tent and sine map?
If A is your matrix [r,c] = find(A==V) will return the row(s) and column(s) where A matches the value V.

8 years ago | 0

| accepted

Answered
Divide a dataset into subsets
This is what you're after, I think. No need for a loop over each point in chanPOz N = numel(markers) ; % pre-allocate th...

8 years ago | 0

| accepted

Answered
Assigning Multiple Vectors in a Structure Field
I think you're looking for this: for j=1:2 b(j).a = [1 0 0] ; % assign vector to field end which can be easier ...

8 years ago | 0

Answered
Hi, I am new to Matlab, so please excuse the simplicity of this question. I have the (x,y) positions of a scatter plot. I would like matlab to fit multiple straight lines to my data. I need Matlab to determine optimal hinge points.
If you have access to the Signal Processing Toolbox, the function *findchangepts* might be useful <https://uk.mathworks.com/hel...

8 years ago | 0

Answered
How to find the lowest and highest rows in a column vector which contain a value.
idx = ~isnan(A); lowestRow = find(idx, 1, 'first') highestRow = find(idx, 1, 'last')

8 years ago | 1

Answered
how to multiply displayed xvalues on plot by constant
Here is one approach: % create plot x=-10:2:10 y = x.^2 plot(x,y,'bo-') % modify labels for tick marks...

8 years ago | 5

| accepted

Answered
The logic behind extracting the values in all corners of a 2-dimensional matrix
You might expect that A([r1 r2],[c1 c2]) returns only two elements, namely A(r1,c1) and A(r2,c2). As you now have seen,...

8 years ago | 0

Answered
How to convert integer vector with the 1-of-K coding sheme into a matrix?
Here are two easy one-liners: Y = [2 2 1 3 2 4 1 4 4 3]; M1 = full(sparse(Y,1:10,1)) M2 = accumarray([Y(:) (1:10).'],...

8 years ago | 1

Answered
Insert array into matrix within a loop
Just to make sure: X has 100 columns, You have a function that takes a column and returns a row-vector of 50 columns. And now yo...

8 years ago | 0

Question


How to check if output argument is ignored?
Is is possible to check if a function gets called with to-be-ignored output arguments (using ~)? function [Y1, Y2] = MyFunc...

8 years ago | 1 answer | 2

1

answer

Answered
How to make a structure from structures?
If A, B, etc. are similar structures you can simply concatenate them. An example % data A = struct('x', 1, 'y', 2) ...

8 years ago | 0

Answered
How to search a substring in a list of strings?
In recent releases you can use startsWith A = {'xx', 'abc1', 'abc2', 'yy', 'abc100'} tf = startsWith(A,'abc') B = A(t...

8 years ago | 1

Submitted


slidefun
apply function to a moving window over a vector (v5, jan 2018)

8 years ago | 1 download |

5.0 / 5

Answered
Sliding window central value divided by window RMS
Maybe you can use my function SLIDEFUN which you can download from the File Exchange: <https://uk.mathworks.com/matlabcentral/f...

8 years ago | 0

Answered
pi as a sum
My take would be to " _Write a matlab function_ ": function p = LeibnizPi(n) p = 0 ; for k = 1:n p = p + % fill...

8 years ago | 0

Answered
How can I find the indices of the repeating elements in an array with respect to another array?
Here is a simple for-loop approach: a=[1,2,3,3,4,5,5,7,8,2] ; b=[1,2,3,3,2 2 2,4,5,5 999] ; % see my comments above ...

8 years ago | 0

| accepted

Answered
Sub values into multiple rows and columns simutaneously
The words " _a few_" and " _others remaining zero_" might indicate that you also could use SPARSE matrices. For instance: A...

8 years ago | 0

Submitted


rot3d90(A, X, K)
Rotate 3D array over 90 degrees in a particular plane

8 years ago | 1 download |

0.0 / 5
Thumbnail

Answered
Good method to store pyramid shaped cell array?
If you have too many void cells in an array, you could consider a sparse encoding scheme, where you store the indices and the co...

8 years ago | 1

Load more