No BSD License  

Highlights from
ReadMaplePlot

4.0

4.0 | 3 ratings Rate this file 4 Downloads (last 30 days) File Size: 820 Bytes File ID: #11513

ReadMaplePlot

by Paulo Fonte

 

24 Jun 2006 (Updated 10 Jul 2006)

Imports into Matlab the data that Maple uses for its plots

| Watch this File

File Information
Description

Maple is a great tool for symbolic manipulation and is also very smart at plotting expressions, handling discontinuities,etc.

However the plot customization and export possibilities are very primitive. Also, often I want to superimpose Maple plots with other data. This is very clumsy to handle in Maple.

Here is a fast solution: import into Matlab Maple's plot structure, where all points are stored.

MATLAB release MATLAB 7.0.4 (R14SP2)
Other requirements .
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
28 Sep 2006 Steve Richardson

Just what I was looking for.

28 Sep 2006 Steve Richardson

This code crashes when there are multiple curves on the same plot that have different numbers of points in each curve. This could be corrected by returning the data in a cell array. For example, use

X=cell(length(start),1);
Y=cell(length(start),1);

for n=1:length(start)
    eval(['d=' fileIn(start(n)+7:ends(n)-1) ';']);
    X{n}=d(1:2:end);
    Y{n}=d(2:2:end);
end

The plotting code would have to be changed into a loop in order to reflect the new data structure.

23 Apr 2007 Rethnakaran Pulikkoonattu

A useful one, especially that matlab EPS file is far nicer on Latex. Maple require a lot of fine tuning to export figure to produce a neat Latex document.

Anyway, as Steve pointed out, multiple curves on a single plot require a minor modification. Steve has already suggested one here. Here is a working example (included the plot).

Note: I have adapted it from Steve's solution

function [X,Y]=ReadMaplePlot(filename, Figure_Title)
% reads into matlab the data in a Maple plot structure
%
% in Maple 10 do
% > P:=plot(whatever multiple 2D plot); # this creates the plot structure. Plot in Maple with display(P);
% > FileTools[Text][WriteString]( "MaplePlot.txt", convert(P,string));
% > FileTools[Text][Close]( "MaplePlot.txt" );
%
% in Matlab do
% >> [Xdata, Ydata]=ReadMaplePlot('MaplePlot.txt','title, if you want a plot');

fileIn = char(textread(filename,'%s','whitespace','','bufsize',50000));
start=regexp({fileIn},'CURVES('); start=start{:}
ends=regexp({fileIn},',COLO'); ends=ends{:}

X=cell(length(start),1);
Y=cell(length(start),1);

for n=1:length(start)
    eval(['d=' fileIn(start(n)+7:ends(n)-1) ';']);
    X{n}=d(1:2:end);
    Y{n}=d(2:2:end);
end

%
figure(1);
if exist('Figure_Title')
    plot(X{1},Y{1},X{2},Y{2},X{3},Y{3},X{4},Y{4}); % Assuming 4 plots. Adjust accordingly
    title(Figure_Title);
end
legend('Ideal', '\alpha=1/4','\alpha=1/2','\alpha=1/3'); % Put the correct number of legends. Assumed 4 here
title('Your Figure Title');
xlabel('time');
ylabel('BER');

Note2: Maple has a separate toolbox to

24 Mar 2010 Brian Bak

Does anyone know how to extend this for use with surfaces instead of just 2D graphs?

Please login to add a comment or rating.
Updates
10 Jul 2006

Small bugs, like a fixed filename... Sorry.

Tag Activity for this File
Tag Applied By Date/Time
external interface Paulo Fonte 22 Oct 2008 08:30:47
maple plot import Paulo Fonte 22 Oct 2008 08:30:47
external interface Paulo Fonte 27 May 2009 08:28:22
maple plot import Paulo Fonte 27 May 2009 08:28:24

Contact us at files@mathworks.com