Answered
summing element is a cell
sum(cat(3,c{:}),3)

7 years ago | 0

Answered
How can I get matlab to execute one or both parts of a code depending on whether a variable exists?
Avoid checking if variables exist or not (such introspective programming is a path to slow, complex, spaghetti code which is dif...

7 years ago | 0

| accepted

Answered
index of an array multiple same element
>> a = [7,8,8,2,5,6,6,2,6,8]; >> U = unique(a) % the order is the same as C. U = 2 5 6 7 8 >> [R,C] = find(U(:)==...

7 years ago | 1

Answered
Reorganizing cell array according to column
>> data data = [1x33 char] [ 0] [11.7701] [17.9263] [2] [2] [1x33 char] [ 5.5659] [ 0...

7 years ago | 0

| accepted

Answered
Convert a text file to a matrix
fun = @(s)regexp(s,'\t','split'); [fid,msg] = fopen('DML001_Carotid_Pressure_6.txt','rt'); assert(fid>=3,msg) hdr = fun(fgetl...

7 years ago | 0

| accepted

Answered
Contributors metainfo: reputation and more
Congratulations to John D'Errico for reaching 10,000! And with only 1520 accepted answers too... impressive.

7 years ago | 6

Answered
Trying to understand pixel value.
"What am I missing here?" You have ignored the fact that RGB images have three color channels, which in order to generate your ...

7 years ago | 0

| accepted

Answered
Uitable data converison for user precision
Your data is numeric, not a cell array. You already answered your own question when you wrote "I have a uitable with double val...

7 years ago | 0

| accepted

Answered
Creating possible addition of a number
Download John D'Errico's excellent partitions: https://www.mathworks.com/matlabcentral/fileexchange/12009-partitions-of-an-inte...

7 years ago | 2

Answered
Fixing a plot with error message: "Function behaves unexpectedly on array inputs...properly vectorize your function"
"Can someone please explain to me what this error message means? " It means that your function returns a differently-sized outp...

7 years ago | 8

| accepted

Answered
How to set slider's minimum value other than zero in GUI?
Read the error message: Warning: 'slider' control cannot have a 'Value' outside of 'Min'-'Max' range So you just need to also ...

7 years ago | 0

Answered
Plotting In Matlab with three columns?
M = csvread('Query_version.csv',1,0); U = unique(M(:,1)); N = numel(U); C = cell(2,N); for k = 1:numel(U) X = M(:,1)==U...

7 years ago | 1

| accepted

Answered
Single representation of same values in a Matrix
>> M = [5,5,3,3,4,4;5,5,3,3,4,4;2,2,1,1,5,5] M = 5 5 3 3 4 4 5 5 3 3 4 4 ...

7 years ago | 0

| accepted

Answered
generating sequence of given numbers
>> A = [0,1,2]; >> M = perms(A) M = 2 1 0 2 0 1 1 2 0 1 0 2 0 ...

7 years ago | 1

| accepted

Answered
how to write metadata information to a jpg file
https://www.mathworks.com/matlabcentral/answers/152559-writing-exif-data-to-jpg https://www.mathworks.com/matlabcentral/fileexc...

7 years ago | 1

| accepted

Answered
How to pick numbers in text file in matrix format
Simple and efficient: opt = {'HeaderLines',1, 'CollectOutput',true, 'EndOfLine','>', 'WhiteSpace',' \n\r\t'}; fmt = [repmat('%...

7 years ago | 0

| accepted

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

Load more