How to change data into an excel file?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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!
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!