From: Naftali Herscovici on
Hello,

Problem1 --------------------------------------------------------------------------------

I am trying to make a chart in excel from matlab.
I downloaded an example shown below:


% White Background, Border off
co.Chart.PlotArea.Interior.ColorIndex = 0;
co.Chart.PlotArea.Border.LineStyle = 0;
% Major Gridlines off (x-axis is 1, y-axis is 2)
co.Chart.Axes(2).HasMajorGridlines = 0;
% Tick Marks inside
co.Chart.Axes(1).MajorTickMark = 'xlTickMarkInside';
co.Chart.Axes(2).MajorTickmark = 'xlTickMarkInside';
% x-axis label
co.Chart.Axes(1).HasTitle = 1;
co.Chart.Axes(1).AxisTitle.Text = 'x-axis';
co.Chart.Axes(2).HasTitle = 2;
co.Chart.Axes(2).AxisTitle.Text = 'y-axis';
% Chart Title
co.Chart.HasTitle = 1;
co.Chart.ChartTitle.Text = ['Chart in s' int2str(j)];

I tried to guess the commands for the VB equivalent:

.Axes(chAxisPositionBottom).Scaling.Minimum = XMIN
.Axes(chAxisPositionBottom).Scaling.Maximum = XMAX
.Axes(chAxisPositionBottom).MajorUnit = DX
.Axes(chAxisPositionBottom).NumberFormat = "###0.00"
.Axes(chAxisPositionLeft).Scaling.Minimum = YMIN
.Axes(chAxisPositionLeft).Scaling.Maximum = YMAX
.Axes(chAxisPositionLeft).MajorUnit = DY
.Axes(chAxisPositionLeft).NumberFormat = "###0.00"

And also the commands for having the plot area closed from all 4 sides (in this example the top bar and the right bar are missing).

Any ideas?

Also is there a documentation for this?

Problem 2 ---------------------------------------------------------------------------

I am trying to make a function that will do this chart, when excel is open in the calling routine.
Is this possible? What are the variables that need to be passed to the function? Can you pass objects to the function or do I need to use GLOBAL?

Thanks

Tuli
From: Steven_Lord on


"Naftali Herscovici" <tuli01(a)hotmail.com> wrote in message
news:i26pc3$a6l$1(a)fred.mathworks.com...
> Hello,
>
> Problem1 --------------------------------------------------------------------------------
>
> I am trying to make a chart in excel from matlab.
> I downloaded an example shown below:

*snip*

> Any ideas?
>
> Also is there a documentation for this?

Search Microsoft's website for the documentation on Microsoft Excel's COM
interface.

> Problem
> 2 ---------------------------------------------------------------------------
>
> I am trying to make a function that will do this chart, when excel is
> open in the calling routine.
> Is this possible? What are the variables that need to be passed to the
> function? Can you pass objects to the function or do I need to use GLOBAL?

Automatically? I don't know. Of course, you can simply have your function
that opens Excel also create the chart (or call a function that does.)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: dpb on
Naftali Herscovici wrote:
....

> I am trying to make a chart in excel from matlab.
....

I'd just ask "why?" What can't you do more directly in Matlab?

--
From: Rich Ellis on
Would the section entitled, "Inserting MATLAB Graphs Into Excel
Spreadsheets" in the MATLAB documentation be useful? Search for this title
in the MATLAB product documentation to see if using an activex server would
work for your requirements.


"Naftali Herscovici" <tuli01(a)hotmail.com> wrote in message
news:i26pc3$a6l$1(a)fred.mathworks.com...
> Hello,
>
> Problem1 --------------------------------------------------------------------------------
>
> I am trying to make a chart in excel from matlab.
> I downloaded an example shown below:
>
>
> % White Background, Border off
> co.Chart.PlotArea.Interior.ColorIndex = 0;
> co.Chart.PlotArea.Border.LineStyle = 0;
> % Major Gridlines off (x-axis is 1, y-axis is 2)
> co.Chart.Axes(2).HasMajorGridlines = 0;
> % Tick Marks inside
> co.Chart.Axes(1).MajorTickMark = 'xlTickMarkInside';
> co.Chart.Axes(2).MajorTickmark = 'xlTickMarkInside';
> % x-axis label
> co.Chart.Axes(1).HasTitle = 1;
> co.Chart.Axes(1).AxisTitle.Text = 'x-axis';
> co.Chart.Axes(2).HasTitle = 2;
> co.Chart.Axes(2).AxisTitle.Text = 'y-axis';
> % Chart Title
> co.Chart.HasTitle = 1;
> co.Chart.ChartTitle.Text = ['Chart in s' int2str(j)];
>
> I tried to guess the commands for the VB equivalent:
>
> .Axes(chAxisPositionBottom).Scaling.Minimum = XMIN
> .Axes(chAxisPositionBottom).Scaling.Maximum = XMAX
> .Axes(chAxisPositionBottom).MajorUnit = DX
> .Axes(chAxisPositionBottom).NumberFormat = "###0.00"
> .Axes(chAxisPositionLeft).Scaling.Minimum = YMIN
> .Axes(chAxisPositionLeft).Scaling.Maximum = YMAX
> .Axes(chAxisPositionLeft).MajorUnit = DY
> .Axes(chAxisPositionLeft).NumberFormat = "###0.00"
>
> And also the commands for having the plot area closed from all 4 sides (in
> this example the top bar and the right bar are missing).
>
> Any ideas?
>
> Also is there a documentation for this?
>
> Problem
> 2 ---------------------------------------------------------------------------
>
> I am trying to make a function that will do this chart, when excel is
> open in the calling routine.
> Is this possible? What are the variables that need to be passed to the
> function? Can you pass objects to the function or do I need to use GLOBAL?
>
> Thanks
>
> Tuli
>


From: Andy on
dpb <none(a)non.net> wrote in message <i26u6q$h2t$1(a)news.eternal-september.org>...
> Naftali Herscovici wrote:
> ...
>
> > I am trying to make a chart in excel from matlab.
> ...
>
> I'd just ask "why?" What can't you do more directly in Matlab?
>
> --

MATLAB certainly has the ability to put both data and graphics into Excel without the use of actxserver. However, as far as I know actxserver is the only way to let Excel know about the relationship between the graphics and the data. This is very useful for, as an example, having MATLAB generate reports that others can change after their own analysis (possibly directly in Excel, and on machines without MATLAB).

Naftali, where did you download this example? Since we can't run the code ourselves, we can't tell, for example, what you mean by "the top bar and the right bar are missing".

>I am trying to make a function that will do this chart, when excel is open in the calling routine.

What does this mean? Are you trying to have a function that runs automatically when Excel is opened? (And if so, should it run when any Excel window is opened, or only for a specified file?) Or are you trying to have it run automatically when MATLAB is started? Or should it run when a program that you've created in MATLAB is run?

As for documentation, you should consult the Excel Developer Reference: http://msdn.microsoft.com/en-us/library/bb242656%28office.12%29.aspx

But the examples in this documentation will all be VB, not MATLAB. And as far as I know there is no documentation available on how to translate between VB-style arguments and MATLAB arguments. A lot of it is guess-and-check for me, but it's usually pretty quick.