Answered
Get one element from each row but not the same column
All six permutations of sums selecting one value from each row: >> N = 3; >> A = randi(9,N,N) A = 8 4 8 9 6 7...

8 years ago | 2

Answered
what does the L-shaped bracket mean?
Those brackets are actually the common way in mathematics to represent the floor function: https://www.mathsisfun.com/sets/func...

8 years ago | 2

Answered
Matrix element changing with loop
5 is a scalar. A scalar has size 1x1. On the second loop iteration a has size Nx2 (we don't know the actual size because you di...

8 years ago | 0

| accepted

Answered
how do you check that a value input into your code is exactly 7 digits long before proceeding?
idNumber = '1234567'; assert(numel(idNumber)==7,'Wrong length ID number')

8 years ago | 0

Answered
Change colour order and restore it
"I want to change figure colour order" Figures do not have a ColorOrder property, only axes do. It is easy to change the axes'...

8 years ago | 2

Answered
How can I generate an array of binary data of this form?
It might not be the most beautiful algorithm in the world, but this works (on 64 bit MATLAB) for even N values up to at least N...

8 years ago | 1

| accepted

Answered
Conditional function creating with @ handle
Directly for this specific calculation: >> f = @(x,y) x + y*(1-2*((x*y)<=1)); >> f(1,2) ans = 3 >> f(2,1) ans = 3 It wor...

8 years ago | 1

| accepted

Answered
Passing data through fminsearch
You should definitely avoid global variables. For your situation the easiest way to parameterize a function is to use a simple ...

8 years ago | 1

Answered
Any suggestion on how to solve this problem using Matlab?
I know this is homework, but someone needs to show that it is a waste time writing loops, it is much better to write simple vect...

8 years ago | 0

Answered
Duplicate every element of a matrix to NxN elements
>> M = [1,2;3,4]; >> kron(M,[1,1;1,1]) ans = 1 1 2 2 1 1 2 2 3 3 4 4 3 3 4 4

8 years ago | 0

| accepted

Answered
accumarray does not return the correct sum
Your data: hdr = {'Date','ID','x','y','z','Profit'}; arr = {... '01-Jan-2019' 157350 0 1 100 0.470000000000000 '01-Jan-2019'...

8 years ago | 1

Answered
Strange behavior of the editor in the forum
Unfortunately the new editor does not work with Windows high-contrast mode, most of the toolbar buttons end up totally blank: ...

8 years ago | 2

Answered
where (what package) is the Matlab's wvd function?
Signal Processing Toolbox. You can easily find this out yourself using the online help, simply finding that page using your fav...

8 years ago | 0

Answered
Using cellfun() to set cell array of graphic objects 'Visible' Property to 'off'
You will need to define an anonymous function like this: cellfun(@(g)set(g,'Visible','off'),your_cell_array_of_handles) Note t...

8 years ago | 2

| accepted

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

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

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

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

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

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

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

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

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

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

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

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

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

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

8 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 = ...

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

8 years ago | 0

Load more