## MAPLE To MATLAB...

 >

Paramétres

 >
 (1.1)
 > beta := 30;
 (1.2)
 >
 (1.3)

 >
 >
 (1.4)
 >
 (1.5)

Résolution & plots

 >
 (2.1)
 >
 (2.2)
 >
 (2.3)
 >

ET

 >
 (3.1)
 >
 (3.2)
 >
 >
 (3.3)
 >
 (3.4)

Hi evey ones ;

how can i convert these code below TO matlab

thank a lot Maple_to_MATLAB.mw

## Generation of a random array...

To gererate a random initail cofigration -1 or 1

spin = (-1).^(round(rand(N)));

for i=1:1000,

neighbours = circshift(spin, [ 0 1]) + ...

circshift(spin, [ 0 -1]) + ...

circshift(spin, [ 1 0]) + ...

circshift(spin, [-1 0]);

how to do this in maple?

## Replica of MATLAB code in Maple?...

hi

if possible to convert matlab file in to maple fie program??convert_to_maple_program.txt

thanks

## From MATLAB code to Maple one...

this is the matlab is it possible to rewrite it in simple maple code

J = rand()+1e-10;

function [M, num, E] = ising(N,J)

B = 0;

M = []; % The total magnetic field of the system

E = []; % The total energy of the system

randTol = 0.1; % The tolerance, dampens the spin flip process

% First we generate a random initial configuration

spin = (-1).^(round(rand(N)));

% Then we let the system evolve for a fixed number of steps

for i=1:1000,

% Calculating the total spin of neighbouring cells

neighbours = circshift(spin, [ 0 1]) + ...

circshift(spin, [ 0 -1]) + ...

circshift(spin, [ 1 0]) + ...

circshift(spin, [-1 0]);

% Calculate the change in energy of flipping a spin

DeltaE = 2 * (J*(spin .* neighbours) + B*spin);

% Calculate the transition probabilities

p_trans = exp(-DeltaE);

% Decide which transitions will occur

transitions = (rand(N) < p_trans ).*(rand(N) < randTol) * -2 + 1;

% Perform the transitions

spin = spin .* transitions;

% Sum up our variables of interest

M = sum(sum(spin));

E = -sum(sum(DeltaE))/2; % Divide by two because of double counting

% Display the current state of the system (optional)

image((spin+1)*128);

xlabel(sprintf('J = %0.2f, M = %0.2f, E = %0.2f', J, M/N^2, E/N^2));

set(gca,'YTickLabel',[],'XTickLabel',[]);

axis square; colormap bone; drawnow;

end

% Count the number of clusters of 'spin up' states

[L, num] = bwlabel(spin == 1, 4);

#############################

## Is Ising a package?...

Hi all

Is Ising a package?

for i = 1:12000

%while (1),

% Choose a random value between 0 and 1 for the interaction strength

J = rand()+1e-10;

% Perform a simulation

[M, N, E] = ising2(n_grid, J);

% Records the results

Ms = [Ms M/(n_grid^2)];

Es = [Es E/(n_grid^2)];

Ns = [Ns N];

Js = [Js J];

i = i+1;

## How to rearrange equations...

Hello,

I have a complex set of non linear diff eqns in the form :

y1'' = f(y1',y1,y2'',y2',y2,y3'',y3',y3,y4'',....,y6'',y6',y6,u1,u2,u3,u4) ;

y2'' = f(y1'',y1',y1,y2',y2,y3'',y3',y3,y4'',....,y6'',y6',y6,u1,u2,u3,u4)

and so on ... y6''=(...)

As I want to resolve this coupled systeme in matlab using @ODE45... I wanted the equations in the form : y1''=f(y1',y1,y2',y2,....) and so on ... => X'[] = f(X[],U[])

How can I force maple to rearrange a system of coupled eqns with only the variables i want ?

I know this is possible beacause it is a nonlinear state space model but maple do not work with nonlinear state space model... It give me error when I tried to create statespace model with my non linear diff eqns.

Thanks a lot !

## Help with MATLAB code...

Hello

I am a student of an engineering career

The math teacher is going to ask us to solve some exercises Matlab

The teacher is very hard and explains nothing of Matlab in class

We must learn to use the program on our own viewing internet watching tutorials

I was wondering if somebody could help solve some exercises.

Are only three exercises which are imposible to me

I would appreciate it greatly.

Thank you

My e-mail :

alessagosti1@gmail.com

## MATLAB connectivity problem ...

Environment: Maple2015, MATLAB_R2014b(MacOSX10.8.5), 2015b(MacOSX10.11.4)

MapleToolbox2015.1MacInstaller.app was successfully completed (log tells us), but when MATLAB were booted, following error messages appeared and symbolic operations of maple failed.

This would be closely related to maple installation on MATLAB as such errors never occur for clean install of MATLABs and looks independent on OSX versions. Now javaforosx.dmg in use by instruction of Maplesoft.  Something wrong is in Maple2015. Note maple-MATLAB link works normally.

Please provide us with direction of how to fix it hopefully by Maplesoft professionals.

(Quote of MATLAB command window display)

at jogamp.common.os.MachineDescriptionRuntime.getPointerSizeInBytesImpl(Native Method)

at jogamp.common.os.MachineDescriptionRuntime.getRuntimeImpl(MachineDescriptionRuntime.java:138)

at jogamp.common.os.MachineDescriptionRuntime.getRuntime(MachineDescriptionRuntime.java:124)

at com.jogamp.common.os.Platform.<clinit>(Platform.java:228)

at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:83)

at com.mathworks.hg.peer.JavaSceneServerPeer.initializeJOGL(JavaSceneServerPeer.java:114)

at com.mathworks.hg.peer.JavaSceneServerPeer.<clinit>(JavaSceneServerPeer.java:100)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:190)

>> maple();

error: maple (line 178)

Invalid MEX-file '/Applications/MATLAB_R2014b.app/toolbox/maple/maplemex.mexmaci64':

Referenced from: /Library/Frameworks/Maple.framework/Versions/2015/bin.APPLE_UNIVERSAL_OSX/libhf.dylib

Expected in: /usr/lib/libSystem.B.dylib

in /Library/Frameworks/Maple.framework/Versions/2015/bin.APPLE_UNIVERSAL_OSX/libhf.dylib

>> syms x  y

error: sym (line 186)

Invalid MEX-file '/Applications/MATLAB_R2014b.app/toolbox/maple/maplemex.mexmaci64':

Referenced from: /Library/Frameworks/Maple.framework/Versions/2015/bin.APPLE_UNIVERSAL_OSX/libhf.dylib

Expected in: /usr/lib/libSystem.B.dylib

in /Library/Frameworks/Maple.framework/Versions/2015/bin.APPLE_UNIVERSAL_OSX/libhf.dylib

error: sym (line 56)

assignin('caller',varargin{i},sym(varargin{i}));

(Unquote)

## Bound of while loop...

Hello all,

here the programme I think there are some mistakes couldnot know where please any comment will be helpful:

# Firstly, set the size limit for the grid, which shall define how many
# points there are in both the vertical and horizontal direction
size=40;
# limit is a variable used to set an unobtainable upper bound
limit=size+1;
# x defined, starting at 1, and two other variables ud (upper diagonal) and
# dd (downward diagonal) begin at 0. All three are used to iterate through
# line creation

x=1;
ud=0;
dd=0;
# Iteration through x, using the line function to create a number of
# horizontal lines up to the limit point

while(x<(limit))
line([0, size], [x, x]);
x=x+1;
end

# Now iterating through the diagonals pointing upwards, using two sets of
# lines, both starting from the line going through the origin. The first
# iterates through the lines that pass through positive x values at y=0,
# the second iterates through the lines passing through negative x values
# at y=0
# ud must be increased by 2 each time to ensure that equilateral triangles
# are formed.

while(ud<(limit))
line([(ud), (size)], [0, (size-ud)]);
line([0, (size-ud)], [(ud), (size)]);
ud=ud+2;
end

# Similar to before, except this time iterating through downward pointing
# diagonals.

while(dd<(limit))
line([(dd), 0], [0, (dd)]);
line([(size), (dd)], [(dd), (size)]);
dd=dd+2;
end

# xvector and yvector set up as two vectors holding x and y co-ordinates of
# points respectively.

xvector = zeros(1, limit);
yvector = zeros(1, limit);

# Reinitiallising x and y values for iterative purposes.

x=0;
y=0.5;
n=1;

# The program now iterates through potential y values for the potential
# points. Then it tests the value of y to see what orientation the lattice
# is at that point, then randomly selects x values to enter, iterating
# between all the possible x values in the orientation before moving on to
# the next y value.

while(y<size)
if(mod(y,1)==0.5)
x=0.5;
while(x<size)
z=rand;
if(z>0.5)
xvector(n) =x;
yvector(n) =y;
n=n+1;
end
x=x+1;
end
elseif(mod(y,2)==1)
x=0;
while(x<size)
z=rand;
if(z>0.5)
xvector(n) =x;
yvector(n) =y;
n=n+1;
end
x=x+2;
end
else
x=1;
while(x<size)
z=rand;
if(z>0.5)
xvector(n) =x;
yvector(n) =y;
n=n+1;
end
x=x+2;
end
end
y=y+0.5;

end

# The program then enters the two co-ordinate vectors saved previously into
# the scatter function.

hold;
scatter(xvector, yvector);

## Calling MATLAB from Maple...

Is this what is supposed to happen when linking Maple to Matlab?  I was hoping it would open the actual Matlab program and write variables to the current worksheet.  I'm I missing something?

Nothing even pops up on the Matlab Command window. What good is this?

## How to import matrix from MATLAB? ...

Hi guys,
I want to import symbolic matrix from matlab to Maple, How I can do that ?

## Is there an analog of MATLAB tilde?...

Hey,

I wonder if there is an operator to skip inputs and outputs of functions. Consider this example:

The output would be:

However my system is much bigger and I only need the second output of the command and I dont want to waste memory on the first.

In Matlab I would write

~,ans := GenerateMatrix(...)Is there a similar shortcut availible in Maple?

## Exporting plot data to MATLAB...

Hello all,

I am pretty new to Maple, but I am trying to understand something. I was able to find a numerical solution to a PDE in maple (with some community help, thanks guys!). I am trying to manipulate this data but am struggling with it. I thought if I could take this data to matlab it would be pretty easy for me to manipulate and do what I want.

So my question is: How do I export my numerical solution (pds module) to matlab. Just taking the data is okay. I know you can evaluate the data at some points.

I see there is "Matlab" command that converts code, it doesn't seem to like pds as an input though.

I also see an export matrix command. I guess it could be possible to create a matrix of plot data and convert it this way?

I had to do a change of coordinate system to solve the PDE because of boundary conditions. I'm trying to transform this data back to my regular x,y coordinate system to see if it matches some other simulations.

Thanks in advance! And here is my file.

restart;
with(Physics):
Setup(mathematicalnotation = true):

V(Z, f);

If function ( varphi) is defined, use this one.

PDE1 := subs[inplace](x = xi*varphi(t), PDE1);
If function ( varphi) is defined, use this one.

PDE1 := subs[inplace](t = 2*vartheta*(1/omega), PDE1);

Thesis_Pde2_attempt.mw

## How to obtain damping ratio of experimental data w...

Hi everybody,

I have some experimental data from an oscillating system (time domaine) and I would like to get an approximation of the damping ratio (zeta). I have already try to use the half-power band width method with the vibrationdata Matlab package designed by Tom Irvine. But I would like to double-check the result with another method.

I found several methods in this paper and I would like to try to do the curve fitting method with the Curve Fitting Toolbox of Maple or Matlab (R2014b) (2.2.2 Curve fitting in the paper). data.txt

It's the first I use this Toolbox with a custom equation, so, I do not really know how to do it with my sample data.

Can anybody help me with this ? I have attached the .txt file sample data to this post.

Cheers