acer

32333 Reputation

29 Badges

19 years, 322 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Earl I don't see how any of the other responses can directly search Maple's 2D Input, since that is stored in a .mw file as a base64 encoding of a .m (dotm) Maple encoding.

@Earl You have not yet clarified whether you need to deal with searching 2D Input.

Here is a rough illustration of the approach I mentioned.

restart;

T := proc(f::string, loc, str::string, {convertmw::truefalse:=false})
   local file, res, w;
   w := interface(warnlevel=0);
   try
     if convertmw then
       file := Worksheet:-WorksheetToMapleText(cat(loc,"/",f));
     else
       file := FileTools:-Text:-ReadFile(cat(loc,"/",f));
     end if;
     res := evalb(StringTools:-Search(str,file)>0);
   catch: res := false;
   finally
     interface(':-warnlevel'=w);
   end try;
   return res;
end proc:

dir := cat(kernelopts(homedir),"/mapleprimes"):

mwfiles := FileTools:-ListDirectory(dir,':-returnonly'="*.mw"):

nops(mwfiles);

4156

select(f->T(f, dir, "odeplot", 'convertmw'), mwfiles[1..100]);

["Praw.mw", "1 (2).mw", "polar_odeplot.mw", "Vertical_Flat_Plate-Numeric-Komathi2.mw", "SondeII_(1).mw", "how_transition_ac.mw"]

mplfiles := FileTools:-ListDirectory(dir,':-returnonly'="*.mpl"):

nops(mplfiles);

13

select(f->T(f, dir, "sscanf"), mplfiles);

["DeleteBadCharcters.mpl"]

txtfiles := FileTools:-ListDirectory(dir,':-returnonly'="*.txt"):

nops(txtfiles);

28

select(f->T(f, dir, "cos(x)"), txtfiles);

["output_of_dsolve.txt", "inflect.txt"]


Download file_search.mw

Of course, for plaintext .mpl or .txt files there are more efficient tools. But that's beside the point if you need to search through 2D Inputs.

note: Worksheet:-WorksheetToMapleText has some limitations, eg. it cannot handle embedded components (and possibly GUI Tables).

Please don't spawn a completely separate Question thread for a close followup query about this system.

You could add your followup details here, instead.

@Carl Love It did contain Danish characters.

The past four or five corruption reports have all been of the same flavour: an unclosed and empty Equation XML element. I'd never seen that particular variant prior to Maple 2022.2.

I have submitted them all as bug reports. In each report for this past group (five of this same variant, Dec2021-Feb2022) I have mentioned two distinct flaws:
  1) that it happens at all
  2) that the GUI is incapable of recovering as much as possible from the corrupted file, and sometimes very little of what is possible.


ps. These corrupted files do not have the "bad characters" for which Joe Riel made a repair script some years ago. That was a different flavor of problem -- which I do not recall seeing for several years.

Why do you think that your procedure's do-loop would ever end?

@Ahmed111 Sorry, I was looking at the wrong file -- you gave the same name to both your original and your revised attachments.

There are still mix-ups involving names like lambda__1 and lambda[1], H__34 and H[34], etc, with both present in some expressions, even in the 2D Input of assignments.

That happens in (at least) the 2D Input of the assignments to vvalueA2snum, and valphipsi12.

@zenterix Someone (perhaps you, the OP) tagged this Question as "pointplot3d". I suggest that makes the Maple Help page for the pointplot3d command a decent starting place for help with programmatic options for that very command.

As I explained, the general programmatic 3D plotting options Help page is linked from there, in two ways.

The Portal pages are very much skewed towards mouse-pointer based context-menu approaches. It's almost as if they were written with the idea that programmatic approaches are undesirable.

I'm not suggesting that you've done anything wrong; I'm simply trying to assist you with some friendly advice in your future programmatic Maple endeavors.

ps. If I search for "light" in the Maple help browser then the mentioned plot3d,option topic page is the second hit down in the returned Search Results. Perhaps it ought to be the top hit.

@zenterix Here is a way to sort a Matrix by a given column. I'll use the second column.

M := Matrix([[11,4,13],[21,-8,23],[31,1,33]]);

Matrix(3, 3, {(1, 1) = 11, (1, 2) = 4, (1, 3) = 13, (2, 1) = 21, (2, 2) = -8, (2, 3) = 23, (3, 1) = 31, (3, 2) = 1, (3, 3) = 33})

M[sort(M[..,2],output=permutation)];

Matrix(3, 3, {(1, 1) = 21, (1, 2) = -8, (1, 3) = 23, (2, 1) = 31, (2, 2) = 1, (2, 3) = 33, (3, 1) = 11, (3, 2) = 4, (3, 3) = 13})

Download sort_Matrix_by_column.mw

I would agree that it might be generally useful to have a Help page that contained common Matrix&Vector manipulations.

There are some manipulation commands (for Arrays, Matrices, & Vectors) in the ArrayTools package.

@zenterix It is not difficult to restructure the Matrix/Array of data. For the kind of regularly structured data you've described, the convertArrayToTable approach is very poor (relatively speaking). I was surprised that you returned to using it.

In fact I already showed you one way to do it directly and easily, using just seq and the angle-bracket constructor. The resulting Matrix can work directly with either surfdata or listdensityplot.

There are other ways to reassemble that data in a way that can be plotted directly, eg. the data can be rewritten as mxnx3, say, and "transposed. And there are still more ways, involving top-level easy commands. You seem so insistent that this quite basic task is difficult that's I think I should give up now.

@zenterix Did you notice that I specified the ytickmarks in the earlier listdensityplot example?

You can specify whatever you want for xtickmarks as well. Just for example,

     xtickmarks=[seq(100*i=100*(0.5+(i-1)*0.5),i=1..6)]


ps. I might not have made the following point clear enough before: I think that the idea of the convertArrayToTable procedure is poor. If your new data has the same kind of pattern (repeated blocks of indices in column 2, etc) then you could get rid of that procedure altogether. Using it is just asking for the kind of difficulties that you had earlier. For the earlier regular data you gave, it could be replaced just by this,   

read "./matrix.m":
m1 := Matrix(m1,datatype=float[8]):
MM:=`<|>`(seq(m1[1+120*(i-1)..120+120*(i-1),3],i=1..85)):

It's more robust as well as much terser. If your data is structured similarly then you could simply adjust for the new dimension sizes. I can't show you directly because you have not provided the new data.

@nm You are objecting to something about a case that you do not know for sure is in the domain that the OP is considering, and which can be handled trivially regardless.

But it might possibly be useful to the OP, so thanks.

More important IMO is that there is already a StringTools command to count the number of occurrences of a single character (ie. no need to write one's own), and that there is another existing command if one wants to tally all characters present.

@mmcdara The OP showed that it was interms of only volts in the Question, since the forced conversion to V^2 works.

@nm It's worth pointing out that evalc makes the assumption that the unknown names are real.

So, while this approach does attain the target it is unnecessarily confusing because it makes it appear that the transformation might depend on such properties or assumptions.

@Mike Mc Dermott There already is an option on the Tabulate command for specifying the relative widths of the columns. It's the weights option.

Combined with the options to specify the total width in either pixels or portion of the worksheet's width, that allows for complete specification of the column widths.

First 82 83 84 85 86 87 88 Last Page 84 of 591