Answered
reading data after a string
Here is one way, assuming that the block of data is the last content that you have in the file. If not, I can update the answer....

12 years ago | 0

| accepted

Answered
how to use nargin function to take variable input arguments and return sum of those arguments
Well, if you had a function function x = doSomething(a, b, c, d) ... end |nargin| would tell you how many input ar...

12 years ago | 1

| accepted

Answered
problem in converting double Array into character?
Just "type cast" to char: >> numberplate = char(a) numberplate = 1132 In your code, you convert to strin...

12 years ago | 1

| accepted

Answered
Daily values to monthly sums
Well, TGIF anyway! Assuming that |iFeb1| is irrelevant (if not, the solution can be updated). % - Vector of months start d...

12 years ago | 0

| accepted

Answered
Changing names within a data
You can proceed as follows, assuming that classes are initially stored in file |classes.txt| and that you want to create file |c...

12 years ago | 0

Answered
read in only certain columns of big text file
I'd do it as follows, assuming that what you don't want to do is to have to build the _formatSpec_ by yourself. We read the firs...

12 years ago | 3

| accepted

Answered
Import CSV file according to timestamp
You could do something like the following (not tested): function selection = getFilesYearMonth( folder, year, month ) f...

12 years ago | 1

| accepted

Answered
Vectorization of 2 for loops in MATLAB
It is not trivial to "vectorize" this setup, as there are operations that require some look up table, and there is accumulation ...

12 years ago | 1

| accepted

Answered
How to vectorise loop to improve performance
If I understand well, have a table of class code, and let's say x and y coordinates Class 'A' 'B' 'C' 'A' 'B' ...

12 years ago | 1

Answered
creating a .res with 2 variables side by side (2 columns)
If your |.res| file is a basic text file, you can proceed as follows dlmwrite( 'myFile.res', [X,Y], 'delimiter', ' ' )

12 years ago | 1

| accepted

Answered
can we use 'and' condition in "for"
You can't, it is always for loopIndex = someArray ... end which is not condition-based. You can do it with WHILE ...

12 years ago | 0

| accepted

Answered
How to read all lines in txt file satisfying some condition
The following is assuming that you have one pair number/string per line in the file. match = regexp( fileread('myFile.txt'),...

12 years ago | 0

Answered
How to organise data based on a large range of numbers?
You can build a look up table, use it to create a vector of season IDs which match column 8 of your data, and then use the latte...

12 years ago | 0

| accepted

Answered
Produce bin averaged latitude and longitude grids
Assuming that longitudes are in the range |[0,360[| and latitudes in the range ]-90,90[, here is part of a solution that you cou...

12 years ago | 0

| accepted

Answered
How do I print a cell array with vectors of different length to an ascii file
Here is an example, assuming that a white space as separator is fine for you and that you want to write these vectors in the fil...

12 years ago | 1

| accepted

Answered
Search a text file for a particular string and then read all values in that line in which string is present into MATLAB
content = fileread( 'myFile.txt' ) ; tokens = regexp( content, 'v =\s*\[([^\]]+)', 'tokens' ) ; values = sscanf( tokens...

12 years ago | 2

Answered
Sort sequencial data from an array into separate arrays
You can proceed as follows to create blocks of consecutive numbers: A_num = [A{:}] ; bStart = [0, find(diff(A_num)>1), ...

12 years ago | 1

| accepted

Answered
Replace values in matrix (text to value)
Here is a small example using the following content vehicle trip_time A B C C23432 1234556 NULL NULL NULL C23...

12 years ago | 1

| accepted

Answered
If statement with OR operator to create error message for a function
if A~=8 && A~=12 && A~=16 error('..','...') ; end you could also use ISMEMBER: if ~ismember(A, [8, 12, 16]) ...

12 years ago | 0

| accepted

Answered
How can I access element with same index from multiple cells
>> extract = @(C, k) cellfun(@(c)c(k), C) ; >> extract(a, 1) ans = 1 1 1 1 >> extract(a, 3) ans =...

12 years ago | 1

| accepted

Answered
column wise reshaping of the 3rd dimension?
>> AA = reshape( permute(A, [3,2,1]), 1, [] ) AA = 1 100 1000 2 200 2000 3 300 3000 4 400 4000

12 years ago | 2

Answered
Why does Matlab not complete if the runtime for a computation is too long?
You should output all the information that you can, i.e. loop counters, branch of conditional statements, etc. If it's slowing d...

12 years ago | 0

Answered
Reading in a document full of code
*Simple answer below, and a more complete function in comment #3. Code is attached to the comment.* You can use a REGEXP to...

12 years ago | 1

| accepted

Answered
how can concat cell array with array?
s = {1; 2; 3; 4} ; % Column cell array. f = [10 20 30 40] ; % Row numeric array. c = [s, num2cell(f.')] ;

12 years ago | 0

Answered
Question on reading datafile in matlab
Here is a start assuming that it is not for a homework (in the sense that a REGEXP-based approach would probably not be accepted...

12 years ago | 0

| accepted

Answered
How to sort data once it is read into matlab
The first column of |data| is a cell array of strings, whereas columns 2 and 3 are numeric arrays. You cannot concatenate them w...

12 years ago | 0

| accepted

Answered
Importing text files into variables with the same name
Your attempts are not bad; we usually avoid using EVAL when possible and we don't generate variable names dynamically (I've seen...

12 years ago | 1

| accepted

Answered
How can I change multiple lines in a text file?
Just for fun, here is a one-liner for reading/replacing (that I write on 3 lines for sake of clarity): repl = regexprep( fil...

12 years ago | 1

Answered
From vertices to Equations of the Plane
Hint: you can start with the following and implement the few additional computations required (realizing that a 4th parameter mu...

12 years ago | 0

| accepted

Answered
Problem with sparse matrix - HELP
[i,j,s] = find( H ) ; Note that most often, when building a sparse matrix with vectors of indices/values, it is relevant t...

12 years ago | 1

| accepted

Load more