I have a .txt file that I need to turn into a vector
9 ビュー (過去 30 日間)
古いコメントを表示
My .txt file is just "2 4 3 4". I need to turn this into a vector but I dont know how.
I loaded my .txt file into the document by going Grades = load("Grades.txt"); then I tried to make that into a vector by doing CourseGrade = linspace("Grades") but it didnt work. It wants me to put real numbers in there.
Please help me out, thanks!
0 件のコメント
回答 (2 件)
Walter Roberson
2022 年 10 月 6 日
filename = 'Grades.txt';
%first create an example file
example_data = "2 4 3 4";
writelines(example_data, filename);
dbtype(filename)
%now do the work
Grades = load(filename)
%Grades is now a row vector because that is what was in the file.
%if you need it to be a column vector then transpose it
Grades = Grades.'
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!