Answered
Removing unique numbers whilst comparing two structures
A loop and ismember makes this clear and easy. An alternative would be to merge the X and Y data, and then call setdiff in the l...

7 years ago | 1

| accepted

Answered
Help improving the speed of find
Loops, loops, loops... so many loops! Better to vectorize your code: B = 1+sum(bsxfun(@ge,x(:),A),3)

7 years ago | 2

| accepted

Answered
Double Precision is rounding at the 5th digit?
Change the display format., e.g. format long g Although beginners often confuse the two, how data is stored in memory and how ...

7 years ago | 3

| accepted

Answered
two column vector division
"two column vector division" All of your examples use row vectors, not column vectors. "What is a mathematical formula?" See ...

7 years ago | 1

Answered
How does the function contains behave ??
The contains function behaves exactly as I would expect, based on its documentation, which states "If pattern is an array contai...

7 years ago | 0

| accepted

Answered
Adding elements of double arrays inside cell array below another double array inside the same cell array
Concatenating the contents of a cell array is easy using a comma-separated list: >> A1 = cat(1,Sort{1,:}) A1 = 1 2 ...

7 years ago | 1

| accepted

Answered
Index exceeds number of array elements?
On each loop iteration the loop iterator variable R_e is scalar (i.e. it has size 1x1). Inside the function you define i=1 and t...

7 years ago | 0

Answered
Conversion of multidimensional cell into string
Using Guillaume's cell array defined above: >> C(:,2) = cellfun(@(v)char(v+'0'),C(:,2),'uni',0) C = 2 '010' 73 '01...

7 years ago | 1

| accepted

Answered
Load multiple struct 1x1 mat files
It is recommended to load into an output variable, rather than directly into the workspace. doing so also makes your task simple...

7 years ago | 0

| accepted

Answered
A command like "unique" for matrices?
A general solution that does not concatenate the data and works for any size arrays: % Fake data: A = [1;2;3]; B = [1;2;3]; ...

7 years ago | 1

| accepted

Answered
How can i seperate a string in all possible smaller ones without using for loops;.
>> a = 'ATGCA'; >> n = 2; >> x = hankel(1:n,n:numel(a)).'; >> b = num2cell(a(x),2) b = 'AT' 'TG' 'GC' 'CA'

7 years ago | 1

| accepted

Answered
Function day not working
''Unable to use a value of type 'datetime' as an index.'" That error message makes it quite clear: you have a variable in the w...

7 years ago | 2

| accepted

Answered
Convert cell arrays to 4-D array
Where C is your cell array: M = cell2mat(permute(C,[4,3,2,1]))

7 years ago | 1

Answered
Simultaneous Changing of Values in For Loop.
Usually it is much easier to increment over indices, not data: t0 = 0; t = t0; Iv = 1:1:3; Jv = 2:1:4; for x = 1:numel(Iv)...

7 years ago | 1

| accepted

Answered
fprintf command output and extra output
You used the wrong operator. If you want to print to string, use sprintf. "Where is the output=15 coming from..." The fprintf ...

7 years ago | 0

| accepted

Answered
how to remove the repetitive elements from a structure
Data: >> a = struct('position', {[200 300 1],[300 200 1],[250 250 0.5],[230 280 0.6],[300 200 1],[270 150 1]}, 'cost', {[50;90]...

7 years ago | 0

Answered
Help with nested structure
This would be much easier if you had designed your data better. In particular, rather than using nested structures (which are r...

7 years ago | 0

| accepted

Answered
While loop with for loop problem
Perhaps you meant something like this: D = [3 0 0; 0 2 0; 0 0 1]; b = [0; 1; 0]; L = [0 0 0; 1 0 0; 0 1 0]; U = [0 1 0; 0 0 ...

7 years ago | 1

| accepted

Answered
Opening mat files with uiopen and copying data to array
It seems that whoever created those .mat files unfortunately named each structure with the same name as the filename, which just...

7 years ago | 0

| accepted

Answered
How do I extract the same field from diferent struct files with names like AAA_1, AAA_2... AAA_n?
I suspect that ScanImage is badly written and saves variables (e.g. structures) with a different name in each .mat file. This ma...

7 years ago | 1

| accepted

Answered
Average of several (different, across) structures
Fake data in scalar structures: S1 = struct('A',randi(99,4,3,2),'B',randi(99,4,3,2)); S2 = struct('A',randi(99,4,3,2),'B',rand...

7 years ago | 2

| accepted

Answered
Keeping record of Number of concatenated files
Inside your loop: N = ... the total number of files. C = cell(1,N) for k = 1:N M = ... import the matrix here. M(:,...

7 years ago | 1

| accepted

Answered
Adding certain 'parts' of two matrices
B(2:3,2:3) = A

7 years ago | 0

| accepted

Answered
How to find out whether there is a repetitive element in the columns of a matrix?
"I just want to know whether there is or not." >> any(diff(sort(a,1),1)==0,1) ans = 1 1 0

7 years ago | 2

Answered
TUTORIAL: Why Variables Should Not Be Named Dynamically (eval)
Alternative: save the Fields of a Scalar Structure The save command has an option for saving the fields of a scalar structure a...

7 years ago | 4

Answered
Finding arrays above threshold value
Fake data: AT(1).AX = rand(1,370); AT(2).AX = rand(1,1007); AT(3).AX = rand(1,3957); AT(4).AX = rand(1,6309); AT(5).AX = ra...

7 years ago | 1

| accepted

Answered
How to Convert a column with Char in Cell matrice to Number?
You almost got it right, you just need to split the numeric array into a cell array so that it can be allocated back to the cell...

7 years ago | 1

| accepted

Answered
Could anyone help me how to solve the issue.
Using very basic MATLAB indexing: A = {[1,2],[3,4],[7,5,6]}; N = numel(A); Z = nan(1,N); for k = 1:N Z(k) ... your code...

7 years ago | 0

| accepted

Answered
Create a 20x24 matrix with each individual column with random integers without duplicate
You do not need a loop, here is a much simpler solution in just one line: >> [~,M] = sort(rand(20,24),1) M = 16 20 17 ...

7 years ago | 0

Answered
How to dissect a file path and keep extension Matlab
Do NOT use path as a variable name! This shadows the important inbuilt path function. To get the file extension use fileparts: ...

7 years ago | 1

| accepted

Load more