I am new to Matlab and just wrote small script to calculate the cooling cycle for my device. I would like to know how can I clear contents of the excel file i created before posting new results to it when its over written.
For ex, when I run my code for 1500 temp degree, I get two columns from A1:B50
now when I run again with temp of 1200, I get the results in the same excel but overwritten with range A1:B40… however, i will still see B40:B50 from the old results which is very confusing.
so I would like to know of a away that before i save the results, clear all the contents i had previously in the created excel so I can fill it with my new results.
here is my code
Code:
clear all; close all; clc;% this program calculates the cooling cycle temps for
prompt = 'What''s your temperature? '; x = input(prompt); sheetnumber = 'Enter sheet number where results will be stored.. '; sheetnum = input(sheetnumber); filename = 'temp_increaments.xlsx'; y = x/30; % this is to calculate the stepsize based on 30 mins interval
z = round(y); % rounding the answer to cloeset integer so i can ..
% preallocate bcoz preallocation needs integers.
difference= zeros(1 ,z); % preallocated to save memory
for i = 2:z % *in this sense, 50 steps means every almost 35 seconds..
% .., i decrease another 5% (cooling increament).
x(i) = x(i-1)*0.95; % here is my equation, i use...
% the output of last first calc as the input of second cal
% and so on for 30 steps.
difference(i) = x(i-1) - x(i);endformat longG disp(x) y = x.'; % to save results as column
change= sort(difference, 'descend'); % sorted the results from high temp..
% to low temp so i can see how much i need to change every cooling cycle
disp(change) z= change.'; % same concept as saving y
%------------------------------------------------------------------------
sheet = sheetnum; xlRange = 'A1'; xlswrite(filename,[y, z], sheet,xlRange)
Best Answer