## 79 Reputation

13 years, 252 days

## Adding tick marks a 3-D plot of a matrix...

Maple

I wish to add tick marks to a 3D plot of a matrix.

B:=Matrix(10, 10, [[0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]]):

Below, I draft a plot of this adjacency matrix B . I have adjusted  the position of the domain graph ticks for the x and y axes to be letters at the midpoints of the matrix elements:

tickList := [1.5 = "W", 2.5 = "P", 3.5 = "K", 4.5 = "C", 5.5 = "Y", 6.5 = "F", 7.5 = "X", 8.5 = "H", 9.5 = "T", 10.5 = "E"];

tickmarks = [tickList, tickList, tickList];

matrixplot(B, axes = [0 .. 12, 0 .. 12, 0 .. 12], heights = histogram, axes = boxed, title = "Above adjacency matrix B - axis order 1-10 \n Basis set: {W,P,K,C,Y,F,X,H,T,E}", labels = ["from", "to", ""], orientation = [0, 0, 0], tickmarks = [tickList, tickList, tickList]);

BUT I would like the z-axis not to be the above letters but instead the real (or integer) values of the matrix elements.  How should I do this, while retaining the x and y axes labels as letters located at the ticklist above.

Melvin

## Text searching problem...

Am trying to analyse a set of strings.   Can anyone help?

We have 10 x10 matrix into which we need to add connection score.
ExY := [WPKCPYWFYWCXHY, WPKCTEYFHCFEEE, HYCYTFHYYWWKCE, HYHHTFHKFEYHEH, HKXWYHFECTFFTF, HKWEHPPECWWHTC, HKXWYTPXHFHWYP, HKFEXCTFECXFKP, HKFEYPPEEEPHYW, HYTHCCFEWPPEXX, HKXKXCKFCHTEWK, HYEKPPCKFTWXXW];
Here is the code to create the connection matrix
A__c = A__a+A__d;
.
Blist:=[W,P,K,C,Y,F,X,H,T,E]:# basis letters
nWords:=numelems(ExY):Wletters:=length(ExY[1]):Bletters:=numelems(Blist):A:=Matrix(Bletters,Bletters):# set up dimensions
for iW from 1 to nWords do  # loop through words
for iL from 1 to Wletters-1 do # loop through letters of each word
fromLett:=C(iW,iL); # see char extraction from ExY list above
toLett:=C(iW,iL+1); # ditto
BfromLett:=Search(fromLett,Blist);# column id   <<<<<< the search is returning 0, it works if one uses "A" rather than say fromLett=A
BtoLett:=Search(toLett,Blist);# row id   <<<<<  ditto here
A(BfromLett,BtoLett):=A(BfromLett,BtoLett)+ 1; # add statistic to the A-matrix
end do; # end letter loop
end do; # end word loop
Error, index out of bounds
The search function is failing:
Blist; Wletters; Bletters; nWords; fromLett; toLett; BfromLett; BtoLett; A; iW; iL;
[W, P, K, C, Y, F, X, H, T, E]
14
10
12
"W"
"P"
0
0

[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]

## How to convert print to screen output to...

Maple 2018

I wish to process a string of letters into a list of one or more characters which are comma separated at each change of character. The following function will achieve this, but its output is not as list [ ] in the format required.

Below is a routine to split a character string based on change of character: (ref: https://rosettacode.org/wiki/Split_a_character_string_based_on_change_of_character#Maple)

splitChange := proc (str::string) local start, i, len; start := 1; len := StringTools:-Length(str); for i from 2 to len do if str[i] <> str[start] then printf("%s, ", str[start .. i-1]); start := i end if end do; printf("%s", str[start .. len]) end proc;
splitChange("WPKCPYWYYYXHYY");#

Here is the output:
W, P, K, C, P, Y, W, YYY, X, H, YY

This print-to screen output is not usable, instead I need the output in list format i.e. ListY:= ["W", "P", "K", "C", "P", "Y", "W", "YYY", "X", "H", "YY"].

Background

In my model, each of these character strings is a node of a graph, and their adjacencies represent an edges of a graph.  I aim to automatically map strings into a set of directed adjacencies as output; for example:

AdjSet:= {[W, P], [P, K], [K, C], [C, P], [P, Y], [Y, W], [W,YYY],[YYY, X], [X, H], [H,YY]}.

This set will be the input to a directed graph, e.g:
from which our objective, the adjacency matrix of the nodes can be obtained in MAPLE.

Help

Can someone please help me by modifying the SplitChange rountine so that it produces output in the form of ListY above?

Thanks in anticipation of your help

Melvin Brown

## Parabolic PDE ...

Maple

I am looking for a numerical solver for a parabolic PDE (up to 2nd order derivatives but no mixed ones) on the spatio-temporal domain [X x Y x T], either as an external package or as MAPLE code.

I have coded the method of lines on the domain [X x T] and indeed also used pdsolve as a check for that case. However, pdsolve (numerical) cannot solve the PDEs on the domain [X x Y x T].  The run times and memory requirements for the latter case would of course be significantly greater.

I am about to code up the method of lines (in MAPLE) on the domain [X x Y x T], but am wondering whether there exist external FORTRAN or C code packages that would be faster if called up in MAPLE and whose results would then be post-pocessed in MAPLE.

Does anyone have any suggestions?

MRB

## Transforming a polar plot from 2D into ...

Maple

I am using MAPLE 2016.1.

I have created an animation of points on a polarplot (2D), but would like it to be projected into 3D, with time t being the 3rd axis.  Here is my code for the polarplot animation:

with(plots);
Repltlist := proc (t) options operator, arrow; [[sin(t), 0], [cos(t), (1/3)*Pi], [cos(2*t), (2/3)*Pi]] end proc;
Impltlist := proc (t) options operator, arrow; [[-sin(3*t), 0], [-2*cos(t), (1/3)*Pi], [-cos(4*t), (2/3)*Pi]] end proc;
titleName := "Polar representation of time-dependence of degrees of freedom in configuration space"; captionName := "Re - red, Im - blue";
P := animate(polarplot, [Repltlist(t), color = "Red"], t = -Pi .. Pi, symbol = solidcircle, style = point, color = red, symbolsize = 12, frames = 100, gridlines = true);
Q := animate(polarplot, [Impltlist(t), color = "Blue"], t = -Pi .. Pi, symbol = solidcircle, style = point, color = blue, symbolsize = 12, frames = 100, gridlines = true);
R := display([P, Q], title = titleName, caption = captionName); R;

I have been trying use the plots[transform] to 'lift' this polarplot into 3D:

with(plottools); with(plots);

plrPt(2); f := proc (tt) options operator, arrow; plottools:-transform(proc (r, theta) options operator, arrow; [r, theta, tt] end proc) end proc; display((f(2))(plrPt(2)));

but the last command gives no output.

Can anyone help?

MRB
PS:  I am now attemptiing to do the lift to 3D by using a cylinderplot but would like know why the transform function is not able able to lift the polarplot into 3D.

 1 2 3 4 5 6 Page 3 of 6
﻿