excel data into a single columns using loop
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Does anyone know how to make this data into a single columns with spacing interval using for loop? from top data to bottom data

.

2 件のコメント
Stephen23
2018 年 9 月 30 日
LIM JIAXIN
2018 年 9 月 30 日
Hi stephen, the answer provided by the link doesnt help. maybe you can help me?
採用された回答
ANKUR KUMAR
2018 年 9 月 30 日
What do you mean by equal spacing between each column. You cannot keep blank any element in matrix. You can do in cell. Here is an example.
A=xlsread('example.xlsx')
reshape(A,[],1) %if you want without keeping blank between each column
B=arrayfun(@(x) num2str(x) , A,'uni',0);
C=[B';{'','','';'','',''}];
reshape(C,[],1)
12 件のコメント
LIM JIAXIN
2018 年 9 月 30 日
編集済み: LIM JIAXIN
2018 年 9 月 30 日
Is it possible to have blank space between them? and why is the result different from the command window compare to when i write it into the excel sheet?
ANKUR KUMAR
2018 年 9 月 30 日
編集済み: ANKUR KUMAR
2018 年 9 月 30 日
yes, its possible. Just put them in cell. Output of
reshape(C,[],1)
is
ans =
15×1 cell array
'19'
'18'
'17'
''
''
'19'
'18'
'17'
''
''
'19'
'18'
'17'
''
''
The same is shown in excel too after writing in excel. xlswrite('example.xlsx',reshape(C,[],1),'sheet2','A1')
The output of above command is [see the attached image]
LIM JIAXIN
2018 年 9 月 30 日
It's working! thank you but how do you make the value be 19 19 19, 18 18 18, 17 17 17 instead of 19 18 17
ANKUR KUMAR
2018 年 9 月 30 日
編集済み: ANKUR KUMAR
2018 年 9 月 30 日
Just remove transpose in this line
C=[B;{'','','';'','',''}];
Previously, there was B' , but if you want in this fashion [19 19 19, 18 18 18, 17 17 17], then remove transpose.
LIM JIAXIN
2018 年 9 月 30 日
Thank you!
Final question, let says if there is a row of value [10, 20, 30] at range A1:C1 is added to make the output become [10 19 19 19, 20 18 18 18,30 17 17 17]. however the value of [19 19 19,18 18 18,17 17 17] starts at A3:C5 assuming there is random values in A2:C2. How do i write the code that is able to add the value from A1:C1 to produce the output?
ANKUR KUMAR
2018 年 9 月 30 日
編集済み: ANKUR KUMAR
2018 年 9 月 30 日
You can pass cell number as the argument, where you wish to start.
xlswrite('file.xlsx',C,'sheet1','A1')
LIM JIAXIN
2018 年 9 月 30 日
Maybe you got my intention wrongly. What I meant was that for the previous example, now there is a additional 2 rows of value. So instead of having all the values coming out as the output, I wish to omit row 2. So in turn by combining the values of row 1 and row 3 onwards to give me a output of [10 19 19 19, 20 18 18 18,30 17 17 17] where the value of [10 20 30] comes from row 1 and [19 19 19,18 18 18,17 17 17] comes from row 3 onwards.
ANKUR KUMAR
2018 年 9 月 30 日
Firstly make a matrix or cell in matlab itself what you wish to see in excel file.
>> A=xlsread('example.xlsx')
A =
19 18 17
19 18 17
19 18 17
>> AA=[[10 20 30];A]
AA =
10 20 30
19 18 17
19 18 17
19 18 17
LIM JIAXIN
2018 年 9 月 30 日
That doesn’t work as the values are all from the excel files. Is there a way to do it without manually typing in the value like AA=[[10 20 30]; A]?
ANKUR KUMAR
2018 年 9 月 30 日
Yes surely. MATLAB can do everything what one can think of. Anyways, please attach the excel file and clearly mention your desired output. We will surely help you.
LIM JIAXIN
2018 年 10 月 1 日
https://www.dropbox.com/s/ee9sfwk6z15ntkk/example.xlsx?dl=0 the excel file is inside the link as i reached the limit of uploading files right now. So my input is under sheet 1 and the desired output can be seen from sheet 2.
ANKUR KUMAR
2018 年 10 月 1 日
A=xlsread('example.xlsx')
A(2,:)=[];
reshape(A,[],1) %if you want without keeping blank between each column
B=arrayfun(@(x) num2str(x) , A,'uni',0)
C=[B;{'','','';'','',''}];
reshape(C,[],1)
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Import from MATLAB についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
