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 个评论
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!

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by