I want to put a column of information back into an excel sheet

조회 수: 3 (최근 30일)
Tristan
Tristan 2022년 11월 14일
답변: Tristan 2022년 11월 15일
I'm using an excel sheet to calculate grades
lear all
data = xlsread('CengGrades.xlsx');
Homework = data(:,2);
Incourse = data(:,3);
Project = data(:,4);
Homework_Grade = Homework .* 0.2;
Incourse_Grade = Incourse .* 0.4;
Project_Grade = Project .* 0.4;
HG = Homework_Grade;
IG = Incourse_Grade;
PG = Project_Grade;
Final_Grade = HG + IG + PG;
FG = Final_Grade;
Ik some of the code is redundant, but i like it this way.
I want to input FG or Final_Grade back into the excel sheet

채택된 답변

RAGHUNATHRAJU DASHARATHA
RAGHUNATHRAJU DASHARATHA 2022년 11월 14일
A per my understanding you want to add a new column of information back to the excel sheet.
you can add the following lines of code to do that
data=[data FG]; %to append the new column to the exisitng data
xlswrite('CengGrades.xlsx' ,data,'Sheet1','A1'); % to write the new data to excelsheet
for further more go through the link
  댓글 수: 2
Tristan
Tristan 2022년 11월 14일
The xlswrite command didn't work, I keep getting this error
Error using xlswrite (line 224)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: SaveAs method of Workbook class failed
Help File: xlmain11.chm
Help Context ID: 0
RAGHUNATHRAJU DASHARATHA
RAGHUNATHRAJU DASHARATHA 2022년 11월 14일
you can also do the following
FG= table(FG);
writetable(FG,'CengGrades.xlsx','Sheet',1,'Range','D1'); % D1 is the column of excelsheet.
%you can use column
% of your choice
for more infromation go through this link

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Tristan
Tristan 2022년 11월 15일
Perfect it worked, thanks

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by