How to change data into an excel file?

1 回表示 (過去 30 日間)
Ryan Scott
Ryan Scott 2020 年 5 月 9 日
回答済み: Payas Bahade 2020 年 5 月 11 日
clear;
clc;
X = readtable('FinalProj_TVdata.csv');
Y = readtable('FinalProj_Pdata.csv');
%Convert from Fahrenheit to Kelvin
TempK = ((X{:,1}-32)*5/9)+273.15;
%Determine Volume
V = X{:,2}*0.028;
I want to find out if V gets below 0.29 and if it does then I want to create a new data set with only the numbers before the volume gets to 0.29 and export that to excel. Please help!
  1 件のコメント
Rik
Rik 2020 年 5 月 9 日
Have you done a Matlab tutorial? That should teach you how to do this.

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

回答 (1 件)

Payas Bahade
Payas Bahade 2020 年 5 月 11 日
Hi Ryan,
Logical indexing can be used to extract the required data from the given array. I have created a sample code which extracts the rows from array ‘X’ whose volume is less than 0.29 and saves this data into 'V' which gets further written into excel file ‘dataset.xlsx’. Below is the sample code:
X=[273 0.23; 274 0.24; 275 0.25; 276 0.26; 277 0.27; 278 0.28; 279 0.29; 280 0.3; 281 0.31]; %dummy array
V=X(:,2)<0.29; %logical array
dataset=A(V,:); %array with data that satisfies the given condition
filename = 'dataset.xlsx'; %excel file name
writematrix(dataset,filename,'Sheet',1) %writing dataset into excel file
You can modify the logical condition as required. Please refer these documentation on logical indexing in array and tables for more details.
Hope this helps!

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by