Answered
Logical Not Operation To The Fields Of Struct
No loop required: >> a(1).b = true; >> a(2).b = false; >> a.b ans = 1 ans = 0 >> C = num2cell(~[a.b]); >> [a....

7 years ago | 0

Answered
Read in the the (i,j) values of N number of matrices
Just use a cell array, then you can trivially access the matrices using indexing: https://www.mathworks.com/help/matlab/matlab_...

7 years ago | 0

Answered
Import multiple text files to separate arrays
Following the examples in the MATLAB documentation: https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-f...

7 years ago | 0

| accepted

Answered
Reading data row by row into matlab.
Why not just use dlmread ?: >> M = dlmread('test.txt','',2,0) M = 12 15 12 18 17 19 14 16 0 ...

7 years ago | 0

| accepted

Answered
find length NaN segments
This is simpler and actually works for all horizontal vectors (unlike the accepted answer): >> A = [NaN NaN NaN 1 2 3 4 NaN 3 4...

7 years ago | 1

Answered
Count the occurence of a number in between other numbers
This is simpler and actually works for all horizontal vectors (unlike the accepted answer): >> x = [ 1 0 0 1 1 1 0 1 1 0 0 0 0 ...

7 years ago | 4

| accepted

Answered
How to delete empty cells in a cell array?
Shifts the empty cell to the right, without any explicit loops: c = {11,12,13;21,[],23;31,[],[]} [~,idc] = sort(cellfun(@isemp...

7 years ago | 0

Answered
Sorting a cell of strings using a certain character position
Simpler in two lines: vart = {'Ice011_L_3of3m.mat';'Ice011_P_1of3m.mat';'Ice011_P_2of3m.mat'} [~,idx] = sort(cellfun(@(v)v(10)...

7 years ago | 0

| accepted

Answered
How to assign a struct array to a field of another struct array?
You just need to use a comma-separated list https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https...

7 years ago | 2

| accepted

Answered
Converting cell array containing char to array.
desired_array = vertcat(cell_array{1,1:8}) https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https:...

7 years ago | 0

| accepted

Answered
Looking for an efficient way of finding elements in a cell array of character vectors
Use ismember: ismember(Channels,{'P3','P4','P7','P8'})

7 years ago | 0

| accepted

Answered
I want to insert a groups of ones in between zeros. I want to display all the possibilities.
A not very efficient brute-force method: >> C = repmat({0},1,8); >> C(1:2) = {[1,1,1]}; >> D = num2cell(perms(1:8),2); >> D ...

7 years ago | 0

| accepted

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

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

8 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

8 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

8 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

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

8 years ago | 1

| accepted

Load more