How do you combine multiple commands into a single code for one execution?

I have been working on a side project for the past few weeks. I am analyzing a stock ticker (CHK) and I have plotted it into a figure using created 5 commands that import the data, convert the Excel serial dates into matlab serial dates, and plot. I want to automate this whole process using one command, i.e. importspreadsheet so I can do this for multiple stocks. How do I go about doing that?
Here are my commands:
importfile('chk.xls');
cDate = Date;
cDate = x2mdate(cDate, 0);
str = datestr(cDate, 1);
cDt = cellstr( str );
plot(cDate,DeltaP,'DisplayName','cDate vs. DeltaP','XDataSource','cDate','YDataSource','DeltaP');figure(gcf)
plot(cDate,DeltaV,'DisplayName','cDate vs. DeltaV','XDataSource','cDate','YDataSource','DeltaV');figure(gcf)
plot(cDate,Volume,'DisplayName','cDate vs. Volume','XDataSource','cDate','YDataSource','Volume');figure(gcf)
Thanks!

 채택된 답변

Follow these steps.
1) At the command line, type: edit
2) Paste your code into the blank document you opened in step 1
3) Save As --> importspreadsheet
Now at the command line, type: importspreadsheet

댓글 수: 2

How do I derive the code from the commands above? Don't the commands automatically create code? I want to copy all of the auto-generated matlab code from the commands I shared above.
Nm I figured it out.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2012년 9월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by