Answered
"Improper assignment with rectangular empty matrix
The answer is simple: the values of |t1|, |t2|, and |p| do not have one unique match that satisfies |t1==t2(p)|, which means tha...

11 years ago | 0

Answered
How to get sorted index order for an array?
You can obtain the output indices directly from |sort|: >> [out,idx] = sort([14 8 91 19]) out = 8 14 19 ...

11 years ago | 20

Answered
Check that *.txt file is really a TXT formatted file?
It is important to note that files themselves have no semantic meaning: they are merely lots of bits that can be interpreted in ...

11 years ago | 1

Answered
Conversion serial date back to calender dates in string format.
Here is some code that reads in the complete file (including the header strings), identifies the step size, locates any missing ...

11 years ago | 0

| accepted

Answered
How to support default parameter in MATLAB FUNCTION ?
MATLAB is an interpreted language, not a compiled language, so there is no compiler as such. In any case there is *no* inbuil...

11 years ago | 4

| accepted

Answered
give name to value in row
If you want to allocate multiple values at once then you can use |deal|: >> a = [1 2 3 4]; >> b = num2cell(a); >> [ti...

11 years ago | 0

Answered
How to make each element in a matrix into its own, separate matrix.
You can easily import the whole matrix at once using |textscan|: fmt = repmat('%f',1,9); fid = fopen('easy.txt','rt'); ...

11 years ago | 0

Answered
find a word in sentence by "strfind"
You can simply wrap the |strfind| inside |isempty|, like this: >> ~isempty(strfind('Schroedingers cat is alive!','cat')) ...

11 years ago | 3

| accepted

Answered
Assuming I have 1 x 20 structure arrays, how can obtain the ones that are decreasing element wise?
It is not very clear what you are trying to achieve. Here are some tools that you might find useful. The function that you shoul...

11 years ago | 0

| accepted

Answered
Find other element in row of a matrix
Use the row output of |find| >> A = [ 3 4 ; 1 3; 5 6]; >> [r,c] = find(A==4); >> A(r,1) ans = 3

11 years ago | 0

| accepted

Answered
How tic/toc calculate execution time?
Yes. The documentation clearly states that <http://www.mathworks.com/help/matlab/ref/tic.html |tic|> starts a timer, and <htt...

11 years ago | 0

Answered
How to use textscan to read this .dat file?
It is not clear exactly how this file is formatted, as the text on the page is not a good way to represent files. Please upload ...

11 years ago | 0

| accepted

Answered
How to retrieve 100 highest coefficient from <1x1024> cell array
Although beginners seem to think that storing everything in cell arrays is a great idea, MATLAB because a much faster and more c...

11 years ago | 0

Answered
how i can get the first and second letters in cell data
This can be easily achieved using <http://www.mathworks.com/help/matlab/ref/cellfun.html |cellfun|> and a simple <http://www.mat...

11 years ago | 0

| accepted

Answered
Avoid loops with matrices.
You can use <http://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|> to get the same output, although the |for| l...

11 years ago | 0

| accepted

Answered
changing the cell values into normal columns
A simple one-line solution using <http://www.mathworks.com/help/matlab/ref/sscanf.html |sscanf|> inside of <http://www.mathworks...

11 years ago | 1

| accepted

Answered
Interpolation problem between two 2D global datasets
There is a major discontinuity in the middle of the longitude data, that makes interpolation impossible. Lets find it: >> m...

11 years ago | 0

| accepted

Answered
How to read a .txt file from a certain keyword onwards
This can be done using |textscan|, first to read the file, and then to parse the strings: % Read file: fid = fopen('Clie...

11 years ago | 1

| accepted

Answered
Read txt file into a matrix
Just use <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|>, it only requires a few lines of code: fid = f...

11 years ago | 1

| accepted

Answered
how to replace double vectors from 0 to '000'
Why bother with the loop at all?: >> numbers=[202;0 ;20;0;0;1013;10]; >> X = num2str(numbers,'%04g') X = 0202 ...

11 years ago | 0

| accepted

Answered
double for loop with changing start point at second loop. need help, wrong output.
It is much simpler and neater with <http://www.mathworks.com/help/matlab/ref/hankel.html |hankel|> and <http://www.mathworks.com...

11 years ago | 2

Answered
how can I merge matrices
Even better would be to avoid the loop entirely by using <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|>: >...

11 years ago | 0

| accepted

Answered
I have two coordinates, say x & y. I want to plot them on XY plane, with each reading of x & y by a dot. Is it possible?
You just need to specify the third option |LineSpec|: plot(x,y,'.') The |LineSpec| option is described in the <http://ww...

11 years ago | 0

Answered
create variable name and save
* Instead of concatenating file-paths together, you should use <http://www.mathworks.com/help/matlab/ref/fullfile.html |fullfile...

11 years ago | 3

| accepted

Answered
Which is faster, a row vector or a column vector? Can anyone answer me please?
Perhaps the column, as MATLAB uses column-major memory storage of arrays. But really it is unlikely to make a big difference. ...

11 years ago | 1

| accepted

Answered
difference between sprintf and fprintf
|sprintf| has nothing to do any _"screen"_ or file at all, it just creates a string variable in MATLAB's memory... of course _yo...

11 years ago | 15

| accepted

Answered
Get current axes from multiple figures.
The <http://www.mathworks.com/help/matlab/ref/line.html |line|> documentation clearly lists this syntax: line(X,Y,Z,'Proper...

11 years ago | 0

Answered
How do I create a three-column matrix that consists of the elements, squares, and cubes of a row vector?
You could play around with <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|>: >> v = 1:5; >> pwr = 0:2; ...

11 years ago | 0

Answered
Import text with headers as column values and append to traditional data set
This code reads the complete sample file, and converts those values to numeric: fid = fopen('test import.txt','rt'); dat...

11 years ago | 0

| accepted

Answered
loop over nested functions overwrites variables
*Solution* Those loops are very confused. Neither the |while| nor the |for| loop is being used effectively. * The |for| lo...

11 years ago | 0

| accepted

Load more