필터 지우기
필터 지우기

How to multiple read csv and subject it to formula and look then store in matrix mat for plotting.

조회 수: 3 (최근 30일)
How to multiple read csv and subject it to formula and look then store in matrix mat for plotting.
G1_01=csvread folder path;
n=find number of files in folder
A=2*G1_01(:,1);
B=2*G1_01(:,2);
C=2*G1_01(:,3);
D=2*G1_01(:,4);
%looping of the csv
for r=1:n
Result = [A;B;C;D]
mat(:,r)= Result;
end
mat=mat
hold on
plot(mat)

답변 (1개)

dpb
dpb 2018년 7월 22일
Many Q? here on the same general idea...here's one recent one that should be good outline to follow/modify to specific purposes-- Answer_329697
For some more background the FAQ has more discussion and alternate ways to skin the cat...
There's also a FEX submission Apply-a-function-to-files that has worked pretty well for me for certain instances that hides a lot of the details needed for the file handling.
  댓글 수: 2
joms
joms 2018년 7월 22일
Thanks but i visit your link but its hard applying on my code.
dpb
dpb 2018년 7월 22일
편집: dpb 2018년 7월 22일
"[I] visit your link..."
There actually are three links there, all of which are apropos to the Q?
What, specifically, have you tried out of the FAQ and example using dir to process the files??? I see nothing in the description of the problem that makes such a difficult task.
One issue in your code above is that creating named sequenced variables is a sign of not using Matlab vector operations efficiently.
The snippet
A=2*G1_01(:,1);
B=2*G1_01(:,2);
C=2*G1_01(:,3);
D=2*G1_01(:,4);
...
Result = [A;B;C;D]
is simply
res=2*G1_01(:);
and will result in a 1D vector of all the elements in G1_01 multiplied by 2. Is that really the result wanted--but it's what the semicolon concatenation line as written would do.
Repeating that in a loop is pretty-much "piece o' cake!" -- give it a shot and see where you actually run into a specific problem; folks will be happy to help.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by