由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - how to assign new value to loop variables?
相关主题
Perl 6 改动很大很恶心【包子求助】20M*20M的loop怎么搞?
how to use array to simulate multi loops如何实现N层循环嵌套
怎么判断int a[]的array的实际长度?How to concatenate two .tar.gz files
请教一个C内存泄露问题大牛 in Perl and SED?
How to compare data in an Array and in Xml (转载)python gc question
julia有前途吗? (转载)[合集] 如何能让这个程序快一点呢?太慢了
LabVIEW问题:对高手来说很简单!gvim diff question
请教一道练习题(C,OS)A problem on string parsing (using either grep or perl)
相关话题的讨论汇总
话题: array话题: loop话题: data话题: file话题: each
进入Programming版参与讨论
1 (共1页)
r****x
发帖数: 3613
1
i know i'm new to coding, i have a for loop reading data from a bunch of fil
es. I need to analysis data after I read one file, then use the loop to read
new file. But the data just grows into a bigger array with all the reading
data. How do I avoid this?
X****r
发帖数: 3557
2
If you rephrase your question with better description of your problem
you might be more likely to get an answer here.

fil
read
reading

【在 r****x 的大作中提到】
: i know i'm new to coding, i have a for loop reading data from a bunch of fil
: es. I need to analysis data after I read one file, then use the loop to read
: new file. But the data just grows into a bigger array with all the reading
: data. How do I avoid this?

b**u
发帖数: 1206
3
malloc ptr1 for file1, malloc ptr2 for file2,...
link list for ptr1, ptr2,...
r****x
发帖数: 3613
4
sorry, my problem is I try to load files with loop, each file contains diffe
rent size of array. I need to analyse each file then proceed to next one. wh
en the first array is finished, the 2nd array just adds into the first one,
until the dimensions mismatch. Do you have any solution to this problem?

【在 X****r 的大作中提到】
: If you rephrase your question with better description of your problem
: you might be more likely to get an answer here.
:
: fil
: read
: reading

X****r
发帖数: 3557
5
It's better this time, but you still didn't provide enough information
for anyone to help you out. Which programming language are you using?
How the array are read from file? What prevented you from just creating
a new variable to hold the new array each time?

diffe
one. wh
one,

【在 r****x 的大作中提到】
: sorry, my problem is I try to load files with loop, each file contains diffe
: rent size of array. I need to analyse each file then proceed to next one. wh
: en the first array is finished, the 2nd array just adds into the first one,
: until the dimensions mismatch. Do you have any solution to this problem?

r****x
发帖数: 3613
6
matlab, reading txt files, data seperated by column, I have to use regexp re
ad data. One major problem is I don't know how many rows in each file, thus
I can only use 'while' to read one file. To loop these files, the rows are a
dded one after another, don't know when to stop.

【在 X****r 的大作中提到】
: It's better this time, but you still didn't provide enough information
: for anyone to help you out. Which programming language are you using?
: How the array are read from file? What prevented you from just creating
: a new variable to hold the new array each time?
:
: diffe
: one. wh
: one,

X****r
发帖数: 3557
7
So are you using double loops? i.e. the outer loop for each file and
the inner loop for each row in the current file? If this is the case
why don't you just reset your array/matrix that holds the data to
empty each time before you enter the inner loop?

regexp re
thus
are a

【在 r****x 的大作中提到】
: matlab, reading txt files, data seperated by column, I have to use regexp re
: ad data. One major problem is I don't know how many rows in each file, thus
: I can only use 'while' to read one file. To loop these files, the rows are a
: dded one after another, don't know when to stop.

r****x
发帖数: 3613
8
yes, i use double loops.
i tried this way, but it didn't work out. because inner loop is 'while'
and counter+1, since I don't know the row number of that data, it's just
text files contains numbers.
Any chance to store all the data
eg 2dimensional array into 3 dimensional array (each data with different
siz
e)?

【在 X****r 的大作中提到】
: So are you using double loops? i.e. the outer loop for each file and
: the inner loop for each row in the current file? If this is the case
: why don't you just reset your array/matrix that holds the data to
: empty each time before you enter the inner loop?
:
: regexp re
: thus
: are a

X****r
发帖数: 3557
9
Yes, in matlab you can create cell arrays. Each element of the cell
array is an independent matrix that can has its own dimensions.
Check the help page of 'cell'.

【在 r****x 的大作中提到】
: yes, i use double loops.
: i tried this way, but it didn't work out. because inner loop is 'while'
: and counter+1, since I don't know the row number of that data, it's just
: text files contains numbers.
: Any chance to store all the data
: eg 2dimensional array into 3 dimensional array (each data with different
: siz
: e)?

r****x
发帖数: 3613
10
关键问题还是在第一个文件读完后他不停的继续读,直接全把row加上去了,我实在是
没辙了。。。

【在 X****r 的大作中提到】
: Yes, in matlab you can create cell arrays. Each element of the cell
: array is an independent matrix that can has its own dimensions.
: Check the help page of 'cell'.

相关主题
julia有前途吗? (转载)【包子求助】20M*20M的loop怎么搞?
LabVIEW问题:对高手来说很简单!如何实现N层循环嵌套
请教一道练习题(C,OS)How to concatenate two .tar.gz files
进入Programming版参与讨论
X****r
发帖数: 3557
11
你还是没有把问题表达清楚。什么叫把直接全把row加上去了?说不清楚贴点相关的代码
上来也好啊。

【在 r****x 的大作中提到】
: 关键问题还是在第一个文件读完后他不停的继续读,直接全把row加上去了,我实在是
: 没辙了。。。

r****x
发帖数: 3613
12
column是固定的,只是row要逐行的读,因为不知道每个文件有多少row所以只能用
while

代码

【在 X****r 的大作中提到】
: 你还是没有把问题表达清楚。什么叫把直接全把row加上去了?说不清楚贴点相关的代码
: 上来也好啊。

t****t
发帖数: 6806
13
用while和把所有的row全都加在一个array里没有必然的关系. 别人问你什么叫"直接全
把row加上去了", 你回答因为啥啥啥所以只能用while, 这个叫做答非所问.
我知道你不会编程, 或许心里也很着急, 可是基本的逻辑都没有, 也不提供任何信息,
这样子你还是自己想办法帮自己吧.

【在 r****x 的大作中提到】
: column是固定的,只是row要逐行的读,因为不知道每个文件有多少row所以只能用
: while
:
: 代码

X****r
发帖数: 3557
14
好吧,我虽然觉得我算是很有耐心的人,也相信楼主遇到的只是一个很简单的小问题,
但是这么多帖子下来我还搞不清究竟是怎么回事,看来是无能为力了。

,

【在 t****t 的大作中提到】
: 用while和把所有的row全都加在一个array里没有必然的关系. 别人问你什么叫"直接全
: 把row加上去了", 你回答因为啥啥啥所以只能用while, 这个叫做答非所问.
: 我知道你不会编程, 或许心里也很着急, 可是基本的逻辑都没有, 也不提供任何信息,
: 这样子你还是自己想办法帮自己吧.

s*******e
发帖数: 664
15
我看着都着急,呵呵
matlab我倒是知道些,尽管也不强

【在 X****r 的大作中提到】
: 好吧,我虽然觉得我算是很有耐心的人,也相信楼主遇到的只是一个很简单的小问题,
: 但是这么多帖子下来我还搞不清究竟是怎么回事,看来是无能为力了。
:
: ,

S*********g
发帖数: 5298
16
Not possible in matlab.
you can't have a variable that is 3D while a(1,:,:) has difference size than
a(2,:,:).
However, you can attack this using structure.
a.file1 = (all data in file1 as a 2D array);
a.file2 = (all dall in file2 as a 2D array);
If your data are just a rows of number, why not use matlab's function to
load the whole file into one 2D array ocne for all?
If you can't use matlab's function, only you can tell how to determine you
hit the end of the file. No one else can answer your

【在 r****x 的大作中提到】
: yes, i use double loops.
: i tried this way, but it didn't work out. because inner loop is 'while'
: and counter+1, since I don't know the row number of that data, it's just
: text files contains numbers.
: Any chance to store all the data
: eg 2dimensional array into 3 dimensional array (each data with different
: siz
: e)?

S*********g
发帖数: 5298
17
幸好这几天值班的是你,不是thrust

【在 X****r 的大作中提到】
: 好吧,我虽然觉得我算是很有耐心的人,也相信楼主遇到的只是一个很简单的小问题,
: 但是这么多帖子下来我还搞不清究竟是怎么回事,看来是无能为力了。
:
: ,

r****x
发帖数: 3613
18
thx a million!
it's quite hard for me to start programming, since I never really leanred it
.

than

【在 S*********g 的大作中提到】
: Not possible in matlab.
: you can't have a variable that is 3D while a(1,:,:) has difference size than
: a(2,:,:).
: However, you can attack this using structure.
: a.file1 = (all data in file1 as a 2D array);
: a.file2 = (all dall in file2 as a 2D array);
: If your data are just a rows of number, why not use matlab's function to
: load the whole file into one 2D array ocne for all?
: If you can't use matlab's function, only you can tell how to determine you
: hit the end of the file. No one else can answer your

r****x
发帖数: 3613
19
最后还是解决了,简单地加了一个counter,唉~不是编程序这块料,这么点小问题卡
了我好几天:X

than

【在 S*********g 的大作中提到】
: Not possible in matlab.
: you can't have a variable that is 3D while a(1,:,:) has difference size than
: a(2,:,:).
: However, you can attack this using structure.
: a.file1 = (all data in file1 as a 2D array);
: a.file2 = (all dall in file2 as a 2D array);
: If your data are just a rows of number, why not use matlab's function to
: load the whole file into one 2D array ocne for all?
: If you can't use matlab's function, only you can tell how to determine you
: hit the end of the file. No one else can answer your

1 (共1页)
进入Programming版参与讨论
相关主题
A problem on string parsing (using either grep or perl)How to compare data in an Array and in Xml (转载)
如果python command line positional arguments 里有些是运算,那这种argument 该怎么处理?julia有前途吗? (转载)
如何让C程序在运行时接受键盘控制而终止?LabVIEW问题:对高手来说很简单!
new and delete in c++请教一道练习题(C,OS)
Perl 6 改动很大很恶心【包子求助】20M*20M的loop怎么搞?
how to use array to simulate multi loops如何实现N层循环嵌套
怎么判断int a[]的array的实际长度?How to concatenate two .tar.gz files
请教一个C内存泄露问题大牛 in Perl and SED?
相关话题的讨论汇总
话题: array话题: loop话题: data话题: file话题: each