Answered
Checking for decimals values in input
assert(fix(r)==r,'Input r must be a whole number')

7 years ago | 0

Answered
Why this x == g gave me logic 0?
"Why this x == g gave me logic 0?" Simply because those values are NOT the same. The values that you are trying to compare can...

7 years ago | 0

| accepted

Answered
Continuous slider callback, how to get Value from addlistener?
A typical usage would be like this: addlistener(Handle, 'Value', 'PostSet',@MyCallBack); And note that while MyCallBack is a f...

7 years ago | 2

| accepted

Answered
How to create a function that accepts a vector input
You will need to change all of the linear algebra operators (i.e. "matrix" operations) to element-wise operations (i.e. "array" ...

7 years ago | 0

Answered
If function in matlab
MATLAB is not Excel, and it is better to write code specifically for MATLAB: >> C = {'N','NE','E','SE','S','SW','W','NW'}; >> ...

7 years ago | 0

| accepted

Answered
sort element in cell
You can easily use logical indexing for this: A = {[1,2,3,4,5,8,9,39],[2,3,17,18,25,26,27],[3,4,14,15,16,17,18],[4,5,6,11,12,13...

7 years ago | 0

| accepted

Answered
Function not using given Variables
You will need to use subs: https://www.mathworks.com/help/symbolic/subs.html The loop is superfluous.

7 years ago | 0

Answered
How to save a plot with the name of the file
Use the mfilename function: M = mfilename(); C = {'Fo','Mn','Ni'}; for k = 1:3 F = sprintf('%s%d_%s.jpg',M,k,C{k}) ...

7 years ago | 0

Answered
how to generate permutations of N numbers in K positions
Download Loginatorist's powerful FEX submission combinator: https://www.mathworks.com/matlabcentral/fileexchange/24325-combinat...

7 years ago | 2

| accepted

Answered
How to create a multi-index vectors?
Start by downloading John D'Errico's excellent partitions function: https://www.mathworks.com/matlabcentral/fileexchange/12009-...

7 years ago | 1

| accepted

Answered
Splitting a matrix based on certain values in the rows
No loop required: >> idx = cumsum(all(A==911,2)); >> row = 1:numel(idx); >> fun = @(r){A(r(2:end),:)}; >> C = accumarray(idx...

7 years ago | 0

| accepted

Answered
How to sort the results correctly in this "for" loop?
Simply download my FEX submission natsortfiles: https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filena...

7 years ago | 1

| accepted

Answered
How Can I count the ascending runs in array ?
As KSSV wrote, you might find diff useful: >> y = y([1,1:end]) y = 1 1 1 0 0 1 1 1

7 years ago | 0

Answered
Vectorized Search of substrings in Cell Array
>> t = {'abcde','bcde','abc','ac'}; >> ~cellfun(@isempty,strfind(t,'bc')) ans = 1 1 1 0

7 years ago | 1

| accepted

Answered
To get the column number of max and min number
>> a = [1,5,3,7,4] a = 1 5 3 7 4 >> [~,mxi] = max(a) mxi = 4 >> [~,mni] = min(a) mni = 1

7 years ago | 1

| accepted

Answered
Little Bit Help Required Regarding Loop
"I just want to save all the values means every time when loop run it keep save the last results and save the new results in the...

7 years ago | 1

| accepted

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

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

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

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

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

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

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

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

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

7 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

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

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

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

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

7 years ago | 2

| accepted

Load more