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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by