Answered
Trasform an array of structs with string in an array of structs with numbers
That code is a bit buggy, and it is _not_ doing what you think it is: # Some structures are "preallocated" using |repmat(stru...

11 years ago | 0

Answered
How to plot with lines in a for loop and use legends for each line?
There is no reason to use cell arrays for this code, and it actually causes the problem that you are experiencing. A very good d...

11 years ago | 0

| accepted

Answered
How can I give degree symbol in XTicklabel in a bar graph?
Make sure that the axes' *|TickLabelInterpreter|* property is set to either |tex| or |latex|: <http://www.mathworks.com/help/...

11 years ago | 0

Answered
Comparing two cell arrays of strings of different sizes
Use <http://www.mathworks.com/help/matlab/ref/strncmp.html |strncmp|> (not |strcmp|) to make the code simpler. Loop over the _sm...

11 years ago | 4

| accepted

Answered
how to count the number of consecutive rows less than a given sum?
Assuming that the data is monotonically increasing then this is easy using <http://www.mathworks.com/help/matlab/matlab_prog/vec...

11 years ago | 0

| accepted

Answered
Programming course - question help
You are printing some text in the command window using |fprintf|. The task you were given is not to print text into the command ...

11 years ago | 1

Answered
Index exceeds matrix dimentions
*The Problem* That error message tells us that you are trying to access a non-existent row of a matrix. Your code deletes row...

11 years ago | 1

| accepted

Answered
How to create a pyramid shaped 3D matrix ?
Either: # use a cell array, or # fill the other positions with some value such as |0| or |NaN|: x = 3; for k = x:-1:...

11 years ago | 1

| accepted

Answered
Multiply each column of cell array by column vector
As per your <http://www.mathworks.com/matlabcentral/answers/250895-average-each-element-of-cell-array previous question> you wou...

11 years ago | 0

| accepted

Answered
How to avoid the for loops?
Here is a solution using matrix multiplication and one |bsxfun| call: Order = 5; X = 0:3; Y = 0:5; A = ones(Ord...

11 years ago | 1

Answered
Can anybody explain such a function handle in Matlab?
See: http://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html which explains what you have given in your ques...

11 years ago | 1

| accepted

Answered
Average each element of cell array
The easiest way is to use <http://www.mathworks.com/help/matlab/ref/cat.html |cat|> to concatenate the cell array of numeric arr...

11 years ago | 6

| accepted

Answered
how to delete a row from a matrix
When you use <http://www.mathworks.com/help/matlab/matlab_prog/vectorization.html vectorized code> then this task is simple, and...

11 years ago | 1

| accepted

Answered
How to find a certain string in a cell with variable size
>> TempCell = {{'a1','a2'},{'a3','a4','a8','a7'},{'a2','a1'},{'a9'}}; >> out = TempCell(~cellfun(@(c)any(strcmp('a1',c)),Te...

11 years ago | 0

| accepted

Answered
Write a Function called Is_decreasing that has the output variables yes_no?
Learn to write neat, simple and efficient MATALB code by writing <http://www.mathworks.com/help/matlab/matlab_prog/vectorization...

11 years ago | 0

Answered
string and mod function help
Try converting the input to a numeric vector, it will make your life much easier: >> vec = input('enter provided code: ','s...

11 years ago | 0

| accepted

Answered
How can I remove all fields which start with a certain string?
You would do much better do avoid naming the fields like this anyway. Confusing _data_ and the abstract _variables_ that represe...

11 years ago | 0

Answered
converting hhmmss to seconds
Although you do not give *any* useful information at all in your question about the *file format* or how many of these numbers t...

11 years ago | 1

| accepted

Answered
Why the error with eval does appear in the code?
Using |eval| for such trivial code like this is a really really bad idea, because you remove all of MATLAB's inbuilt code checki...

11 years ago | 1

| accepted

Answered
Getting the Original Variable Name from a Concatenated Matrix
The easiest solution is to not confuse _data_ with the abstract representation of it, the _variables_. Here are two ways youc an...

11 years ago | 0

Answered
How to pass control from one loop to the other loop
There is no need for slow and inefficient loops when <http://www.mathworks.com/help/matlab/matlab_prog/vectorization.html *code ...

11 years ago | 0

Answered
How can I use a nested for loop to find multiple minimum values in a matrix array?
It is easy to get the row and column indices of the minimum without any loops using <http://www.mathworks.com/help/matlab/matlab...

11 years ago | 0

Answered
remove the Text from the files
This is fast and easy using <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|> in a loop: k = 0; opt = ...

11 years ago | 0

| accepted

Answered
Convert Cell Arrays to Doubles
The output that you request is not possible, because the colon character |:| cannot be part of a double array. If you really wan...

11 years ago | 0

| accepted

Answered
subscripted assignment dimension mismatch - Edge effect
Note that whatever method you choose you will have a _different number of elements_ in each sample, which means you will need to...

11 years ago | 0

| accepted

Answered
Editing/Changing a text file's content based on input variable
Try this code: N = 5; % <- how many line to change to '1'. S = fileread('run.txt'); S = regexprep(S, '1\s*?$','0','li...

11 years ago | 0

Answered
A beginners question on reading matrix array
C = {'pants','scarf','heels','shoes'; true,false,true,true; true,true,false,true}; % Index of where both lines are true: ...

11 years ago | 0

Answered
Conditional textscan - How to select certain lines from a file
Usually the fastest and easiest way to select from a dataset is to read the complete file into MATLAB and then make the selectio...

11 years ago | 0

| accepted

Answered
hi. i have two variables which are AREA and PERIMETER.
You could do this in two calls: save(filename,'AREA') ... other code save(filename,'PERIMETER','-append') OR in on...

11 years ago | 1

Answered
Plotting in for loop not working. Averaging matrix over ranges.
It is easy to split your data into groups according to the fourth column: B = [... 0 15 33 0.5 0 15 32 0.8 0 16 32...

11 years ago | 1

| accepted

Load more