I have some data exported in a txt file which has 780 rows x 5 columns. The problem I am running into is that the correct interpretation of the data takes the 1st row, then append the 2nd row onto the first, then the 3rd onto this appended set, and so on...
Does anyone have an elegant way to achieve this? I have included a sample output of just the first two rows as an example:

 採用された回答

the cyclist
the cyclist 2021 年 10 月 24 日
編集済み: the cyclist 2021 年 10 月 24 日

0 投票

It would be much easier for us to help if you uploaded
  • your data file
  • your code (instead of an image of your code)
However, it seems all you need is to take the transpose, and then convert to a vector. I think this will do what you want, but I can't be sure because I can't test it against your data:
T = csvread('matlab test.csv');
temp = T.';
output = temp(:);
The reason for doing the transpose first is that when the last line of code converts to a vector, it is going to read down each column in turn (because that is how the array is stored internally).
FYI, another handy command for doing such manipulations is reshape.

1 件のコメント

Jeffrey Dhas
Jeffrey Dhas 2021 年 10 月 24 日
編集済み: Jeffrey Dhas 2021 年 10 月 24 日
I appreciate the quick response! I have attached the data file. Here is my code as well listed below:
The ultimate goal is to convert all the data into a single row or single column based on the order desired:
clear all; close all; clc
T = csvread('matlab test.csv');
for i = 1:2
new = T(i,:)
a(i) = new(1);
b(i) = new(2);
c(i) = new(3);
d(i) = new(4);
e(i) = new(5);
end
test2 = [a(1); b(1); c(1); d(1); e(1); a(2); b(2); c(2); d(2); e(2)]
%final = [a b c d e]'

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

製品

リリース

R2018a

質問済み:

2021 年 10 月 24 日

編集済み:

2021 年 10 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by