MATLAB Answers

Reading Workspace variable into csv file

조회 수: 7(최근 30일)
Mehul Jain
Mehul Jain 2 Apr 2020
댓글: Mehul Jain 6 Apr 2020
I got above 22 side bands output from 3D DWT, which are represented in the form of matrix. I need to read this into the csv file. Can anyone help me out???

  댓글 수: 6

표시 이전 댓글 수: 3
Mehul Jain
Mehul Jain 2 Apr 2020
CSV format.
Rik
Rik 2 Apr 2020
You misunderstand me. Your matrix is 3D. There are many ways to encode that information into a file that contains comma separated values. Some programs/formats require you to put the coordinates first, followed by the value, with one line per value.
You see the route that Mathworks has chose to display the data: page by page. You could do that as well, but is your program able to understand you mean 17x19x17 instead of 17x323?
Mehul Jain
Mehul Jain 2 Apr 2020
Yes, another program requires in 17x323 format.

로그인 to comment.

채택된 답변

Rik
Rik 2 Apr 2020
The most important thing to do first is to reshape the data to a 2D array. Then we can use the writematrix function as normal.
WT.dec{1,1}=rand(17,19,17);%generate random data
d=WT.dec{1, 1};%store in other variable for shorter syntax
%option 1: 17x323
d1=reshape(d,size(d,1),[]);
%option 2: 289x19
d2=mat2cell(d,size(d,1),size(d,2),ones(1,size(d,3)));
d2=cell2mat(d2(:));
filename='d1.csv';
writematrix(d1,filename)

  댓글 수: 8

표시 이전 댓글 수: 5
Mehul Jain
Mehul Jain 5 Apr 2020
Hey, after writing these matrix into csv file, when i open the file, it is showing that file is corrupted and the another program is not able to undertand that. So can plz suggest any thing for this???
Rik
Rik 5 Apr 2020
What program concluded the file is corrupt? A text editor or your target software?
Mehul Jain
Mehul Jain 6 Apr 2020
Machine learning classifier program.

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그


Translated by