Answered
Create function handle with several variables/arguments
Why not just vectorize the multiplication and summation?: fun = @(z) sum(cv(:).*z(:)); https://www.mathworks.com/help/matlab/m...

7 years ago | 2

| accepted

Answered
How to concentrate matrix 100 times?
Your approach is entirely in the wrong direction: using numbered variables is a sign that you are doing something wrong with you...

7 years ago | 0

| accepted

Answered
How to use the prctile (X,p,'all') function?
According to the MATLAB documentation the 'all' option was added in version R2018b: https://www.mathworks.com/help/stats/releas...

7 years ago | 1

| accepted

Answered
Using the matlab to achieve the a(k)+a(j) when k is not equal to j in every stage
a = [1,2,3,4]; for k = 1:4 b = 0; for j = 1:4 if j~=k b = b + a(k) + a(j); en...

7 years ago | 1

| accepted

Answered
Sum columns of matrix
>> M = [1,5,2,4,3,2;2,3,1,4,4,1;4,5,2,2,3,1] M = 1 5 2 4 3 2 2 3 1 4 4 1 4 5 2 2 3 1 ...

7 years ago | 0

| accepted

Answered
How to split a [30x250x1000] array into 1,000-2D matrices
Just use a simple cell array: function epoch = matrix_extractor(data_class,number_epochs) data_class; C = cell(1,numb...

7 years ago | 1

| accepted

Answered
Too many input arguments
Everywhere you call function HionpH you call it with two input arguments, but you defined the actual function with just one inpu...

7 years ago | 1

| accepted

Answered
Using fprintf to create a table of values
Remember that MATLAB is column-major, so it works down the columns first. Pay careful attention to the orientation of the vector...

7 years ago | 1

Answered
How to vectorize double sum
>> N = 4; >> x = randi(9,3,N) x = 5 4 8 9 2 9 9 8 1 1 4 1 >> F = @(c)bsxfun(@minus,x(:,c),x(:,c...

7 years ago | 1

| accepted

Answered
Increment dates using for loop
>> D = datetime('01-Jan-2018'); >> N = 14; >> G = 3; >> V = D + caldays(0:ceil(N/G)-1).'; >> V = repelem(V,G); >> V = V(1:N...

7 years ago | 0

Answered
comparing columns of cell arrays
As most of the data seem to be numeric encoded as character vectors, then we can easily convert them from char to numeric arrays...

7 years ago | 0

| accepted

Answered
How can I do matrix indexing
A simple and reliable solution using linear indexing: >> f = [1,22,333;4,33,111;1,4,33] f = 1 22 333 4 33 ...

7 years ago | 0

| accepted

Answered
Is there a product function that works in the same way as diff?
"...but instead of difference gives me the product of every other element?" It is not clear what you mean by "every other eleme...

7 years ago | 0

| accepted

Answered
How to compare each element of a matrix with a number? And then star it out
>> V = 1:7; >> N = 6; >> C = cellstr(num2str(V(:))) >> X = V>=N; >> C(X) = strcat(C(X),'*') C = '1' '2' '3'...

7 years ago | 1

Answered
How to get the difference between two numbers in a matrix?
>> A = [20,40;30,60;25,50;10,70] A = 20 40 30 60 25 50 10 70 >> N = size(A,1); >> V = 1:N-1; >> F = ...

7 years ago | 0

| accepted

Answered
How to obtain ORIGINAL columnar indexes of top 3% values.
mat = [1,3,5;1,23,9;123,34,75]; idy = 1:ceil(size(mat,1)*0.03); for k = 1:size(mat,2) [vec,idx] = sort(mat(:,k),'descend'...

7 years ago | 0

Answered
Multi-dimentional arrays with matlab
"i have read that one cannnot work with multi dimentional arrays in matlab" Instead of reading incorrect and/or misleading stat...

7 years ago | 1

Answered
How to delete all the contents in a folder using matlab
Use rmdir(root_dest,'s') % ^^^ you need this to also delete all of the folder contents. This is explained in th...

7 years ago | 2

| accepted

Answered
Converting a base ten number into a base two number?
x = 47.1875; % Integer part: n = 1+fix(log2(x)); I = nan(1,n); y = fix(x); for k = n:-1:1 I(k) = fix(mod(y,2)); ...

7 years ago | 0

Answered
Why does hex2num('F') equal -3.1050e+231?
Try hex2dec instead: >> hex2dec('F') ans = 15 "What function gets the expected result of F = 15?" You can easily find these ...

7 years ago | 0

| accepted

Answered
display a struct as table
First convert all of the row vectors to column vectors, and make sure that they all have the same number of elements (the last...

7 years ago | 0

| accepted

Answered
Splitting a long string into individual variables
"... so I'm looking for a way to split them all into their own variables" That would not be a good approach. Read this to know ...

7 years ago | 0

| accepted

Answered
how i can delete useless data from matrix
Do NOT use a loop for this. MATLAB code should be neat and simple: [~,idx] = unique(data(:,[6,8]),'stable','rows'); out = dat...

7 years ago | 0

Answered
How do I implement sort_nat.m a function for opening and reading files?
You can download my FEX submission NATSORTFILES here: https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-...

7 years ago | 0

| accepted

Answered
Can I Split the char with out deliminater ? (Please have a look at example)
>> str = 'FD86FA78F79B0425FAEE0866031E02F60742F9840240F6C0F999FE4BF6F407FDFE2208330680FEB20680F6'; >> sscanf(str,'%4x') ans = ...

7 years ago | 0

| accepted

Answered
Pass values to outside of loop after each iteration
Based on your comment "output mat with n no. of row would look like = [w, the vector elements , sum]", perhaps using a cell arra...

7 years ago | 0

Answered
Setting array elements to zero, the best way
Use array(:) = 0; at the start of the loop. This will not require new arrays to be created, which is likely faster... but the ...

7 years ago | 0

| accepted

Answered
fclose - what is the purpose?
Short Answer: Files need to be opened and closed for reasons that depend on how OS's work, not because of how MATLAB works. Fil...

7 years ago | 2

| accepted

Answered
How can i generate this array with matlab?
In two simple steps: >> V = 4:10:194 % 1st step V = 4 14 24 34 44 54 64 74 84 94 104 114 ...

7 years ago | 1

| accepted

Answered
the number of files between two elements of a cell
An effiicent method based on simple logical comparisons of numeric vectors (serial date numbers): >> d1 = '20190102'; >> d2 = ...

7 years ago | 1

| accepted

Load more