Answered
vector indexes matrix columns
You can easily calculate the <http://www.mathworks.com/help/matlab/math/matrix-indexing.html linear indices>. X = [1,2,3,4;...

11 years ago | 0

| accepted

Answered
Frequency of element in Matrix
To start I would highly recommend that you learn to *read the documentation* of every function and operation that you use. When ...

11 years ago | 0

| accepted

Answered
Sort one set of data to correspond to another.
>> a = [100,200,300,400,500]; >> b = [300,200,500,400,100]; >> [~,Xa] = sort(a); >> [~,Xb] = sort(b); >> Xa(Xb) ...

11 years ago | 0

Answered
converting 2d matrix to 3d matrix
Try this: Y = reshape(X,257,257,3) For example, a matrix with R, G and B columns, rearranged into a 2*4*3 array: >>...

11 years ago | 0

Answered
Finding a value and call the cell number or counting value on the same length of vectors.
Using <http://www.mathworks.com/help/matlab/matlab_prog/vectorization.html vectorized code> is faster and neater than using a lo...

11 years ago | 1

| accepted

Answered
how can i classify my matrix
In just one line: >> X = [1,2,3,4,5,6;23,3,15,1,32,4]; >> sortrows(X.',2).' ans = 4 2 6 3 1 5 ...

11 years ago | 0

| accepted

Answered
Convert CSV / Array Cell to Dataset
*Solution* Reading the file is easy using <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|> (because |.csv|...

11 years ago | 0

| accepted

Answered
Calling matrix values to strings
In MATLAB the <http://www.mathworks.com/help/matlab/ref/eq.html equality operator> is |==|, not |=|. This is clearly shown in th...

11 years ago | 0

| accepted

Answered
summation using while loop until I get a certain value
This is much easier without any loops: >> N = 43; >> A = [3,4,10,3,9,10,12,4,11,9,11,10]; >> B = cumsum(A); >> C =...

11 years ago | 2

Answered
How to extract data from image figure?
You can use <http://www.mathworks.com/help/images/ref/getimage.html |getimage|>

11 years ago | 0

Answered
Can Matlab randomly generate a combination with groups of varying size?
The problem is essentially the random <https://en.wikipedia.org/wiki/Partition_(number_theory) partitioning> of a vector. Partit...

11 years ago | 1

| accepted

Answered
How to import csv files in Matlab?
Reading multiple files is such a common topic that it is covered very well on our Wiki: <http://matlab.wikia.com/wiki/FAQ#How...

11 years ago | 1

Answered
Solution to IF statement please :)
Note that you should not use numbered variables, as this invariably leads beginners to dynamic variable naming, which is a very ...

11 years ago | 1

| accepted

Answered
Problem with storing data into cell aray
There is nothing wrong. That is how MATLAB displays cell contents if the cell contents are not a simple scalar array or a short ...

11 years ago | 1

| accepted

Answered
Code to import csv file which contains text and numbers
You can use <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|>, which lets you read text and numeric data from...

11 years ago | 0

| accepted

Answered
I get the error 'Subscript indices must either be real positive integers or logicals'? Please help!
Your index is probably going to zero or negative. Consider if |fs*exceptDur| is larger than the length of |x| x = x(end-fs*...

11 years ago | 1

Answered
The output of for loop
This is easy using <http://www.mathworks.com/help/matlab/ref/sprintf.html |sprintf|>: for k = 0000:3000 str = sprint...

11 years ago | 1

Answered
Create animation from cell array
When I use an internet search engine it gives me thousand of pages showing how to do animation with MATLAB, including the offici...

11 years ago | 1

| accepted

Answered
Need Help making a nxn symmetric matrix
Simply use <http://www.mathworks.com/help/matlab/ref/toeplitz.html |toeplitz|>: >> n = 6; >> M = toeplitz([-2,1,zeros(1,...

11 years ago | 2

Answered
Sort Cell array by data
The whole problem could be avoided by using any <https://en.wikipedia.org/wiki/ISO_8601 *ISO 8601* date format> in the strings. ...

11 years ago | 0

Answered
How can I select a random number from a set multiple times without it selecting the same number twice?
for k = randperm(10) disp(k) ... do something with k end

11 years ago | 1

| accepted

Answered
How can I increase my slider by one step?
The slider steps are explained in the <http://www.mathworks.com/help/matlab/ref/uicontrol-properties.html#property_sliderstep UI...

11 years ago | 6

Answered
Add a 2D matrix to a 3D matrix in a specific location
*Method One: Indexing* >> A = randi(10,3,3,3)-1; % 3x3x3 >> B = nan(3,3); % 3x3 >> C(:,:,[1:2,4]) = A; % ...

11 years ago | 0

Answered
If this value of 5x5 cell with vectors [106x1] are different to zeroes,count them e put the count in a matrix.
>> X = {[0,1,0,2];[3,0,0,0];[0,4,5,6]}; >> Y = cellfun(@nnz,X) Y = 2 1 3 >> sum(Y) ans = 6 P...

11 years ago | 2

| accepted

Answered
What inputs have to be scalar and why cannot we raise an exponential within a square root function please?
You probably need to use the <http://www.mathworks.com/help/matlab/ref/power.html _element-wise_ power>, just like the error mes...

11 years ago | 1

| accepted

Answered
finding most common letter in a cell array
This is very simple with |mode|: >> v = +[x{:}]; >> char(mode(v(~any(bsxfun(@eq,v,y(:)))))) ans = n Note: if there...

11 years ago | 0

Answered
Optimization code to avoid the repeating of the same expression
This is easy if we don't use numbered variables (see link below to know why numbered variables usually occur in bad code). The i...

11 years ago | 1

Answered
count number of elements in a cell
>> x={'zyryan';'zythem';'zythia';'zythum';'zyzomys'}; >> numel(x) ans = 5

11 years ago | 0

Answered
Error: Conversion to double from cell is not possible
Most likely the variable |Matrix| is a numeric array, and you are trying to assign a cell array to one of its elements. This is ...

11 years ago | 0

Answered
Average of every n elements of two separate vector
You can use <http://www.mathworks.com/help/matlab/ref/histc.html |histc|> and <http://www.mathworks.com/help/matlab/ref/accumarr...

11 years ago | 1

| accepted

Load more