Answered
Making one structure out of two structures
A general solution for two identically-sized structures, with any number of fields: >> F.A = 'apple'; >> F.B = 'ball'; >> E.C...

8 years ago | 2

| accepted

Answered
Why are values in my loop filled with NaN?
Actually this has nothing to do with division by zero. When you read the NaN help it lists several ways that NaNs can occur: "T...

8 years ago | 1

| accepted

Answered
I wonder the way of reading data for some specific order.
>> sort([1:4:34,2:4:34]) ans = 1 2 5 6 9 10 13 14 17 18 21 22 25 26 29 30 33 34

8 years ago | 1

| accepted

Answered
Sort one Vector according to other Vector in octave
If you use a character array and want to sort its rows, then you need to use the indexing on its rows: Year_Month_Name = Year_M...

8 years ago | 0

| accepted

Answered
How do a get a specific day of the year?
The problem is caused by this line: [year month day] = ymd(date); When you have variables named year, month, and day, then you...

8 years ago | 2

| accepted

Answered
storing char from a cell to a varaible
c = c{1}(1) https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html

8 years ago | 0

Answered
1D series to 2D stacked
In one line: B = A>=(10000:-1:1).' Or for versions prior to R2016b: B = bsxfun(@ge,A,(10000:-1:1).');

8 years ago | 1

| accepted

Answered
How to change file name and convert the file
S = dir('*.jpg'); for k = 1:numel(S) im = imread(S(k).name); im = imresize(im,[256,256]); im = rgb2gray(im); ...

8 years ago | 1

| accepted

Answered
How to change a value in an array when a condition is met?
idx = Velocity(:,3)==0; vec = [1;-1]; Velocity(idx,4) = vec(randi(numel(vec),nnz(idx),1))

8 years ago | 0

| accepted

Answered
How to create an array that counts the number of consecutive repeating numbers in a given array?
>> A = [1;1;1;2;2;2;2;2;3;3;4;4;4;4;4;4;4;5;5;5;5;1;1;1;3;3;3;3;3;3]; >> V = diff(find([1;diff(A)~=0;1])); >> C = arrayfun(@(n...

8 years ago | 0

| accepted

Answered
Splitting an array every n rows
"so ideally M would be:" M{1,:} = Accel(1:80,:) M{2,:} = Accel(81:160,:) etc etc Just use mat2cell: >> N = 80; >> A = ...

8 years ago | 0

| accepted

Answered
Mapping values of two different-length vectors to index-vector
>> [~,X] = histc(a,b) X = 1 1 2 3 3 4 5 6

8 years ago | 1

| accepted

Answered
how to remove rows if only the first row contains a specified value
One Value: the simple MATLAB way, either keeping the other rows: >> X = D(:,1)~=281; >> D = D(X,:) D = 279 6 6 ...

8 years ago | 2

| accepted

Answered
Find out the rows having same values in all columns of a matrix
Something like this should get you started: >> A = [0,0,0,0,1,0,0;1,0,0,0,0,1,0;1,0,0,0,0,1,0;0,1,0,1,0,1,0;1,0,0,0,0,1,0;0,0,0...

8 years ago | 1

| accepted

Answered
How to convert char into string?
>> str = 'd879c14e5b1fa7a413aa46bbbc2b8710'; >> dec2bin(sscanf(str,'%2x')) ans = 11011000 01111001 11000001 01001110 0101...

8 years ago | 0

| accepted

Answered
How to get rid of this error?
"No i want to convert binary vectors higher than 53 bits" MATLAB's native floating point numeric class double does not support ...

8 years ago | 0

Answered
Resize a matrix into another with different size
A simpler solution: >> X = 1:26; >> R = 4; >> N = numel(X); >> M = nan(R,ceil(N/R)); >> M(1:N) = X M = 1 5 9...

8 years ago | 1

Answered
How to define cells' position in array?
M(1,1) % TL M(1,end) % TR M(end,1) % BL M(end,end) % BR

8 years ago | 0

Answered
Why there is no line in my graph?
"Why there is no line in my graph?" Because you are plotting one scalar point on each loop iteration. This will NOT give a line...

8 years ago | 1

| accepted

Answered
Indices and Filling Vectors
Use repelem or kron: >> t = [1,2,1,2,1,3]; >> d = kron(t-1,ones(1,5)) d = 0 0 0 0 0 1 1 1 1 1 0 0 ...

8 years ago | 1

| accepted

Answered
Linear Interpolation without interp1
"I thought there would be some way to identify the previous/next element from the entered x value in the array but I can't manag...

8 years ago | 0

Answered
how do I find the locations of values in a matrix?
Use ismembertol, something like this (untested, but should get you started): DN = datenum(2018,1,1,00,00,00):0.020833:datenum(2...

8 years ago | 0

| accepted

Answered
To refer index of the first number in every column in 3d matrices
Your question is not clear because you ask for "the first number in every column", i.e.: t(1,:,1) t(1,:,2) t(1,:,:) %both Bu...

8 years ago | 1

| accepted

Answered
Assigning numbers to 3d matrix.
t = reshape(1:30,5,3,2) or t = nan(5,3,2); t(:) = 1:30 or t = [1;2;3;4;5]+[0,5,10]+reshape([0,15],1,1,[])

8 years ago | 1

| accepted

Answered
scalar to vector formation, k = [k1 k2 k3 k4] to [k1,-k1,0,0:-k1,k1+k2,-k2,0:0,-k2,k2+k3,0:0,0,-k3,k3+k4]
k = [0.6337,0.6337,0.6337,0.6337]; n = numel(k); m = zeros(n); m(2:n+1:end-n) = 0-k(1:end-1); % lower m(1+n:n+1:end) = 0-k(...

8 years ago | 0

| accepted

Answered
Insert number 1 to certain column and row in a matrices
>> t = zeros(9,10,2); >> t([43,53,62,72,81,97]) = 1 t(:,:,1) = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

8 years ago | 0

Answered
Sorting with high precision
"Is there a way to choose how accurate the sort function is?" No. And rounding is not a good solution, because it introduces ar...

8 years ago | 0

| accepted

Answered
Is there a way to replace a paragraph of lines with another set of lines using regexprep ?
"The problem is I guess the regexprep is not able to read and replace \n ,the newline character." There is absolutely no reason...

8 years ago | 0

| accepted

Answered
randomly change signs of certain elements in a matrix
Do NOT use a loop for this! You can do this very simply with logical indexing: >> a = [1,-1,1;1,1,1;-1,-1,1] a = 1 -1 1...

8 years ago | 0

| accepted

Load more