Message Boards Message Boards

0
|
5107 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Min and Max file .xls

Posted 9 years ago

Hello,

I try to find the minimum and maximum of a .xls file and have those values ??as extremum for a legend ListPlot3D .

When i import my file, I get this :

data = Import["myFile.xls"]
{{{"-28.58", "-26.67", "-26.89", "-26.46", "-26.46", "-26.04", "-25.82", "-25.19", "-24.97", "-24.97", "-34.53", "-37.29", "-40.47", "-40.90", "-40.05", "-38.99", "-38.77", "-38.56", "-38.77", "-38.99"},
{"-41.11", "-40.47", "-40.26", "-40.05", "-40.05", "-40.05", "-39.41", "-37.50", "-34.74", "-33.47", "-34.53", "-37.29", "-40.47", "-40.90", "-40.05", "-38.99", "-38.77", "-38.56", "-38.77", "-38.99"},
{"-40.68", "-40.05", "-40.05", "-39.84", "-40.05", "-40.47", "-40.05", "-37.92", "-35.16", "-34.10", "-35.80", "-38.99", "-41.53", "-40.90", "-39.62", "-38.77", "-38.35", "-38.14", "-38.35", "-38.77"},
{"-40.47", "-40.05", "-39.84", "-39.84", "-40.26", "-41.11", "-41.32", "-39.20", "-36.01", "-34.74", "-35.80", "-39.62", "-42.81", "-41.53", "-39.41", "-38.56", "-37.92", "-37.71", "-37.92", "-38.35"},
{"-40.68", "-40.26", "-40.05", "-40.26", "-40.90", "-42.17", "-43.02", "-39.84", "-36.23", "-34.95", "-36.86", "-41.53", "-44.08", "-41.32", "-39.20", "-38.14", "-37.50", "-37.71", "-37.71", "-38.14"},
{"-41.11", "-40.90", "-40.90", "-41.32", "-42.17", "-44.51", "-45.99", "-41.11", "-36.44", "-34.95", "-36.44", "-41.75", "-46.20", "-42.17", "-39.20", "-37.92", "-37.29", "-37.29", "-37.50", "-37.71"},
{"-41.96", "-42.17", "-42.38", "-43.44", "-45.78", "-50.87", "-48.54", "-40.47", "-35.80", "-34.32", "-36.44", "-43.02", "-48.33", "-42.38", "-39.20", "-37.71", "-37.08", "-37.08", "-37.29", "-37.50"},
{"-41.96", "-42.60", "-43.66", "-45.35", "-48.96", "-54.70", "-45.99", "-39.20", "-34.74", "-33.04", "-34.95", "-41.11", "-52.79", "-43.23", "-39.20", "-37.71", "-37.08", "-37.08", "-37.29", "-37.50"},
{"-38.77", "-39.20", "-40.05", "-40.90", "-41.32", "-40.90", "-38.14", "-34.74", "-31.98", "-31.13", "-33.68", "-40.47", "-56.82", "-43.44", "-39.20", "-37.71", "-37.08", "-36.86", "-37.08", "-37.50"},
{"-33.89", "-34.10", "-34.10", "-34.32", "-34.32", "-33.89", "-33.04", "-31.34", "-29.43", "-29.01", "-31.34", "-37.50", "-52.57", "-45.99", "-39.84", "-37.92", "-37.08", "-36.86", "-37.08", "-37.29"},
{"-29.22", "-29.43", "-29.22", "-29.22", "-29.01", "-28.58", "-28.16", "-27.52", "-26.89", "-26.89", "-30.07", "-36.65", "-52.15", "-45.35", "-39.84", "-37.71", "-37.08", "-36.86", "-37.08", "-37.50"},
{"-26.89", "-26.67", "-26.67", "-26.25", "-26.25", "-25.82", "-25.19", "-24.97", "-24.97", "-25.82", "-28.58", "-34.32", "-45.78", "-48.33", "-40.47", "-38.14", "-37.29", "-36.86", "-37.08", "-37.50"},
{"-26.67", "-26.25", "-26.25", "-26.04", "-25.82", "-25.19", "-24.55", "-24.34", "-24.55", "-25.61", "-28.58", "-34.32", "-46.63", "-47.90", "-40.26", "-38.14", "-37.29", "-37.08", "-37.29", "-37.71"},
{"-28.80", "-28.80", "-28.58", "-28.37", "-27.95", "-27.52", "-26.67", "-25.82", "-25.19", "-25.40", "-27.73", "-33.25", "-43.66", "-51.09", "-41.32", "-38.56", "-37.71", "-37.29", "-37.50", "-38.14"},
{"-33.04", "-33.04", "-33.47", "-33.25", "-33.04", "-31.98", "-30.49", "-28.37", "-26.67", "-26.04", "-28.58", "-34.32", "-45.35", "-49.81", "-41.53", "-38.99", "-37.92", "-37.71", "-38.14", "-38.56"},
{"-38.35", "-38.99", "-39.84", "-40.68", "-40.68", "-38.99", "-35.38", "-31.34", "-27.95", "-26.67", "-28.16", "-33.25", "-42.81", "-52.57", "-42.81", "-39.84", "-38.77", "-38.56", "-38.99", "-39.41"},
{"-41.32", "-41.75", "-43.23", "-45.57", "-51.94", "-48.96", "-38.56", "-32.40", "-28.16", "-26.89", "-29.01", "-33.89", "-42.60", "-50.87", "-43.87", "-41.11", "-39.84", "-39.62", "-39.62", "-40.05"},
{"-40.47", "-40.47", "-40.90", "-41.96", "-45.35", "-53.63", "-41.96", "-34.10", "-29.22", "-27.31", "-28.58", "-32.62", "-39.20", "-46.84", "-46.63", "-43.44", "-41.75", "-40.90", "-40.47", "-40.68"}, 
{"-39.20", "-38.56", "-38.77", "-39.62", "-41.75", "-46.63", "-41.96", "-33.89", "-29.01", "-27.31", "-28.58", "-32.19", "-37.08", "-41.96", "-45.35", "-45.14", "-43.87", "-42.60", "-41.32", "-40.90"},
{"-38.35", "-37.92", "-37.92", "-38.35", "-39.84", "-43.44", "-43.44", "-35.59", "-29.86", "-27.52", "-27.95", "-30.07", "-33.25", "-36.23", "-39.41", "-41.75", "-42.81", "-42.38", "-41.11", "-39.84"}}}

But with Min[data] I have this :

Min["-24.34", "-24.55", "-24.97", "-25.19", "-25.40", "-25.61", "-25.82", "-26.04", "-26.25", "-26.46", "-26.67", "-26.89", "-27.31", "-27.52", "-27.73", "-27.95", "-28.16", "-28.37", "-28.58", "-28.80", "-29.01", "-29.22", "-29.43", "-29.86", "-30.07", "-30.49", "-31.13", "-31.34", "-31.98", "-32.19", "-32.40", "-32.62", "-33.04", "-33.25", "-33.47", "-33.68", "-33.89", "-34.10", "-34.32", "-34.53", "-34.74", "-34.95", "-35.16", "-35.38", "-35.59", "-35.80", "-36.01", "-36.23", "-36.44", "-36.65", "-36.86", "-37.08", "-37.29", "-37.50", "-37.71", "-37.92", "-38.14", "-38.35", "-38.56", "-38.77", "-38.99", "-39.20", "-39.41", "-39.62", "-39.84", "-40.05", "-40.26", "-40.47", "-40.68", "-40.90", "-41.11", "-41.32", "-41.53", "-41.75", "-41.96", "-42.17", "-42.38", "-42.60", "-42.81", "-43.02", "-43.23", "-43.44", "-43.66", "-43.87", "-44.08", "-44.51", "-45.14", "-45.35", "-45.57", "-45.78", "-45.99", "-46.20", "-46.63", "-46.84", "-47.90", "-48.33", "-48.54", "-48.96", "-49.81", "-50.87", "-51.09", "-51.94", "-52.15", "-52.57", "-52.79", "-53.63", "-54.70", "-56.82"]

How can i have only the Min and the Max of this file?

7 Replies

Thanks ! Works well but without "First@" !

Works well thank you ! But how do the limits of the legend ? It doesn't appear : /

graph3D = ListPlot3D[data = Import["myFile.xls"], ColorFunction -> "Rainbow", PlotLabel -> "3D", PlotLegends -> BarLegend[{"Rainbow", {Min[ToExpression[data]], Max[ToExpression[data]]}}]]

Things are much simpler! For the BarLegend you do not even need Min and Max, try:

txtData = { - your imported textdata - };
data = ToExpression[First@txtData];
graph3D = 
 ListPlot3D[data, ColorFunction -> "Rainbow", PlotLabel -> "3D", 
  PlotLegends -> Automatic]

Henrik

POSTED BY: Henrik Schachner

Depending on Mathematica version

   data = {{{"your data"}}};
    Max[ToExpression[data]]
    -24.34
    Min[ToExpression[data]]
    -56.82
Head[data[[1, 1, 1]]]
String

But this may not work in all instances as we don't know content of different xls files you may Import in the future.

POSTED BY: Hans Michel

... well, as one can see your imported data are all strings! Before any calculations can be done they have to be converted (using ToExpression):

txtData = { - your imported data - };
data = ToExpression[txtData];
MinMax[data]

Regards Henrik

POSTED BY: Henrik Schachner

same thing :/

Posted 9 years ago

Min[Flatten[data]]

POSTED BY: Imran Khan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract