Answered
How to convert matrix to 1-D array and back to matrix form?
Use <http://www.mathworks.com/help/matlab/ref/reshape.html |reshape|> to do both of these: >> A = [1,2,3,4;5,6,7,8] A = ...

11 years ago | 0

| accepted

Answered
How to find consecutive values above a certain threshold?
Here is a conceptually very simple method (I changed the third value to 20 as well, to provide a sequence of values > 12 but sho...

11 years ago | 1

Answered
How do I shorten and remove empty elements from a textscan cell array?
Instead of a loop you can use <http://www.mathworks.com/help/matlab/ref/cellfun.html |cellfun|> to detect the empty strings: ...

11 years ago | 0

Answered
Alignment in a .txt file
When you read the <http://www.mathworks.com/help/matlab/ref/fprintf.html |fprintf|> documentation you will find lots of formatti...

11 years ago | 0

| accepted

Answered
Replacing 1's in a vector 'a' with elements of another vector 'b' where a and b are not equal?
>> a = [NaN,NaN,1,1,NaN,1,NaN,1,1,1,1]; >> b = [2,3,4,5,6,7,8]; >> a(a==1) = b a = NaN NaN 2 3 NaN ...

11 years ago | 0

| accepted

Answered
Not enough arguments error when I clearly supply enough arguments?
Try supplying the supplementary function |dart_gun01| as a <http://www.mathworks.com/help/matlab/function-handles.html function ...

11 years ago | 0

| accepted

Answered
How can I change the elements of a matrix in new one?
Instead of slow and painful loops as if MATLAB was some low-level programming language like C, just use simple <http://www.mathw...

11 years ago | 1

Answered
How to build-up a column from top to bottom
The answer to your question is to swap |a| and |u| within the concatenation: u = [u;a] But this is poor MATLAB programmi...

11 years ago | 1

Answered
Creating a row vector where the index of the vector is not equal to its element value
Because your question does not state anywhere that the output needs to be random, then the answer can be quite simple: just shif...

11 years ago | 0

Answered
how to sort the element of one column in a 220*3 matrix in ascending mode, keeping the elements of other columns dependent on the elements of sorted column ?
If you want to move the *entire row* based on how the first column is sorted, then use <http://www.mathworks.com/help/matlab/ref...

11 years ago | 1

| accepted

Answered
Reading big textfile with textscan
*Solution One* You do not need to delete the first ten rows from the file, because <http://www.mathworks.com/help/matlab/ref/...

11 years ago | 1

| accepted

Answered
create a .txt file in a specific folder
Rather than concatenating strings it is much more reliable to use <http://www.mathworks.com/help/matlab/ref/fullfile.html |fullf...

11 years ago | 0

Answered
undefined variable in a for cycle
If you want to pass extra variables to the function then redefine the function to have three (or more!) inputs: function da...

11 years ago | 0

| accepted

Answered
Converting cell 2 matrix get an error if the numbers don't have the same number of digits, why?
Because that cell array actually contains <http://www.mathworks.com/help/matlab/characters-and-strings.html strings>, and does n...

11 years ago | 0

| accepted

Answered
Read some data from a file containing numbers and characters
Of course you can use <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|>, and this is likely to be the fastest ...

11 years ago | 2

Answered
Reading variable names from a loop
https://www.mathworks.com/help/matlab/matlab_prog/string-evaluation.html https://www.mathworks.com/matlabcentral/answers/304528...

11 years ago | 1

Answered
Variable string as filename using export_fig
You need to learn about the difference between function syntax and command syntax: http://www.mathworks.com/help/matlab/matla...

11 years ago | 1

| accepted

Answered
Convert a cell column of strings to doubles
If the data is a cell array of strings, then try using <http://www.mathworks.com/help/matlab/ref/str2double.html |str2double|>: ...

11 years ago | 2

Answered
I want to transfer data from a for loop into a vector, i need to use rows of a matrix, every 3rd number(not every 3rd entry) in first column( 2 to 5 repeated numbers for each, tho random). Prob is output length unknown so difficult to prelocate
We can avoid the loop altogether by using the very efficient <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|> ins...

11 years ago | 0

| accepted

Answered
Quick way to sum array elements based on flag in another array?
Try this: tmp = (1:numel(lost))-[0,cumsum(lost(1:end-1)==0)]; desired = accumarray(tmp.',clean).' Tested: >> cle...

11 years ago | 1

| accepted

Answered
I want to convert the numbers in the matrix as the letter .
To perform this for all elements of the input array you should learn how to write <http://www.mathworks.com/help/matlab/matlab_p...

11 years ago | 1

Answered
How to get most similar row in matrix A to matrix B
By default <http://www.mathworks.com/help/matlab/ref/sum.html |sum|> sums the columns of its input matrix... whereas you want it...

11 years ago | 1

Answered
How to assign 'null values' to certain ranges of an equation based on a criteria?
The simplest solution is to use indexing, as per Guillaume's solution. But this requires the array of values to be defined first...

11 years ago | 0

| accepted

Answered
sin(2*pi) vs sind(360)
Yes, it is because π is a value that cannot be represented precisely using a finite binary <http://www.mathworks.com/help/matlab...

11 years ago | 0

Answered
Importing a CSV file as a nested cell array - is it possible
Here is a simple and neat solution using <http://www.mathworks.com/help/matlab/ref/fileread.html |fileread|> and <http://www.mat...

11 years ago | 0

| accepted

Answered
Attempt to reference field of non-structure array. Error while trying to read txt file
_"why is this?"_ Because this is not MATLAB code: A.length() Structures have fields, but |A| is not a structure. A...

11 years ago | 1

Answered
How to access each digit of a number in matlab without converting it into string?
>> A = 54321; >> rem(floor(A./(10.^(floor(log10(A)):-1:0))),10) ans = 5 4 3 2 1 >> A = 918287...

11 years ago | 2

Answered
Plot a "floating' 3D surface
Replace the zeros with NaNs, and they will not get plotted: X = load('MUHAT_E.txt'); X(X==0) = NaN; surf(X) create...

11 years ago | 1

| accepted

Answered
Extracting the text from pdf file
_"Is there any way to do it?"_ Of course, in principal any data with a known specification can be parsed by MATLAB. Is the...

11 years ago | 2

| accepted

Load more