Beantwortet
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....

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 1

| akzeptiert

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

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 0

Beantwortet
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...

fast 13 Jahre vor | 3

| akzeptiert

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

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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 ...

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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' ...

fast 13 Jahre vor | 1

Beantwortet
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', ' ' )

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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 ...

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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'),...

fast 13 Jahre vor | 0

Beantwortet
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...

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 2

Beantwortet
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), ...

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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]) ...

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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 =...

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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

fast 13 Jahre vor | 2

Beantwortet
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...

fast 13 Jahre vor | 0

Beantwortet
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...

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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.')] ;

fast 13 Jahre vor | 0

Beantwortet
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...

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 1

Beantwortet
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...

fast 13 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 13 Jahre vor | 1

| akzeptiert

Mehr laden