calcLoopPlus_Logo2.png

Japanese2.png

Top page /  Overview & Download /  Tutorials /  Bug info


Tutorials

  1. Calculate expressions
  2. Output results as a graph
  3. An example for file reading function
  4. Read text strings and create bar graph

1. Calculate expressions

With CalcLoop Plus, you can calculate expressions repeatedly while making the value of the loop variable change.

  • Drag and Drop the following expressions into the expression field.

%nograph
x=<100e-6:500e-6:20e-6>@
a=60/sqrt(5)@
a2=0.67*pi*x*(0.8+35E-6/x)@
b={400e-6,600e-6}@
y=a*ln(4.0*b/a2)

In the expressions above, %nograph is one of expression headers, and is used when you want to output the results from the expressions not as a graph but as a numerical list. (Without %nograph, they are outputted to both.) And x is the loop variable and its range is specified in the form of "=<Min:Max:Step>". And parameters are specified in the form of "={,}".

  • Click the Exe button.
  • Calculation results are outputted as a numerical list on the List Pane.

1.000000e-04  50.67577  61.55554
1.200000e-04  47.18039  58.06016
1.400000e-04  44.08830  54.96807
1.600000e-04  41.31600  52.19577
1.800000e-04  38.80349  49.68326
2.000000e-04  36.50623  47.38600
2.200000e-04  34.39024  45.27001
2.400000e-04  32.42898  43.30875
2.600000e-04  30.60135  41.48112
      :          :        :

The values of the loop variable x are outputted as x data to the first column. To the second and third columns, the values of the variable y are outputted as y data up to the same number as parameters.


2. Output results as a graph

Next, let's try to make a graph by using the former expressions again.

  • Remove the %nograph header from the former expressions and add some headers related to graph creation as follows.

If you have the %nograph header, headers related graph will be ignored. the %rangelog header is used for setting a graph axis' scale to log. (The first parameter stands for the kind of an axis, and the second parameter does an axis range which consists max and min values. If it does not have the second parameter, the range will be determined automatically.) The %axislabel header is used for specifying an axis label the kind of which is x, y or y2 axis. The %label header is used for specifying data labels.

%rangelog x (5e-5:0.001)
%rangelog y
%axislabel title "Line width and Impedance"
%axislabel x "width [m]"
%axislabel y "Z0 [Ω]"
%label b=400um b=600um
x=<100e-6:500e-6:20e-6>@
a=60/sqrt(5)@
a2=0.67*pi*x*(0.8+35E-6/x)@
b={400e-6,600e-6}@
y=a*ln(4.0*b/a2)

  • Click the Exe button.
  • Calculation results are outputted onto the Graph pane as a graph. They are outputted also onto the List pane as text at the same time.
clp_tutorial_1.png
  • To turn off legend display, choose the "Hide Legends" item from the Object menu after selecting the graph. And create arrows by choosing the "Line" tool from the tool buttons in the bottom of the window, and move the two data labels to proper positions.

Whether legends are displayed or not in the initial stage is determined depending on a setting in the Preferences panel. And the kind of lines created by the "Line" tool can be set in the Preferences panel.

clp_tutorial_2.png

3. An example for file reading function

If you make use of a file reading function in expressions, you can give some calculation processes to raw data which can be got from experiments and so on.

  • Drag and drop the following data into the Source data field for the fread functions in the upper right part of the window.

3   0.30
4   0.41
5   0.48
6   0.53
7   0.60
10   0.78
20   1.14
30   1.08
40   1.11
50   1.36
60   1.53
70   1.60
80   1.90
100   1.73

Except for using Drag &am; Drop, from the file read button or through the %external header, you can specify a particular file as source data for file reading functions.

  • Drag and Drop the following expressions into the expression field.

%format d f
%symbol l s
%symboltype 0 1
%linetype 6 0
%rangelog x (1:200)
%rangelog y (0.2:3)
%label calc. meas.
%axislabel title "Test Graph"
%axislabel x "F. [Kg]"
%axislabel y "Disp. [m]"
x=fread(0)@
a=0.2227@
b=0.4704@
z=a*x^b@
y={z,fread(1)}

Specify the row number of the source data for the argument of the fread function. Since the fread function can control(*) the loop variable, which means it generates loop of the same number as the source data's rows, you need not prepare the range specification (=<::>) of the loop variable. In this example the first column of the source data is assigned to the loop variable x, and the second column is assigned to the variable y.

(*) There are two types of file reading functions. One is the fread function that reads data sequentially, the other is the fread2 function that reads them at random. The fread function can only control the loop variable.

In this example theoretical values from calculation are plotted on the graph in addition to the source data. To do it, the variable y is substituted to the variable z, which contains theoretical value, and the output of the fread function, which comes from the source data, by using the parameter specification "={,}".

The %symbol header is used for specifying combinations of symbol and line. And the types of symbols and the types of lines are specified by the %symboltype header and the %linetype header respectively.

  • Click the Exe button.
  • Calculation results are outputted onto the Graph pane as a graph. They are outputted also as text onto the List pane at the same time.
  • As well as doing on the former example, turn off legend display and add arrows. And choose the "Show Fonts" from the Window menu to change the tittle's fonts.
clp_tutorial_3.png

4. Read text strings and create bar graph

Using file reading functions makes reading strings data also available. (But for making a graph, the strings that is the output of the function has to be assigned to the loop variable x.) In this example you will try to make a bar graph which has x axis labels generated from the strings.

  • Drag and drop the following data for reading into the Source data field for the fread functions in the upper right part of the window.

China 10794 13784
U.S.A. 16934 7911
"Saudi Arabia" 540 4325
"United Arab Emirates" 704 3672
Australia 1453 3248
"Korea, Rep. of" 5849 3178
Indonesia 858 2807
Taiwan 5131 2365
Germany 2376 2146
Thailand 2665 1964

  • Drag and Drop the following expressions into the expression field.

%xstrings a
%format s f
%symbol s
%rangelin y (0:20:10)
%axislabel title "The amount of Japan exports and imports for principal countries, 2006"
%axislabel y "Unit: trillion Yen"
%label Export Import
x=fread(0)@
z={fread(1), fread(2)}@
y=z/1000

To display x axis labels as strings, the %xstrings header is required. The parameter to the header stands for a display type of x axis labels. (The parameter "v" means the labels are laid out vertically.) The %format header is used for specifying data formats when the results are outputted to the List pane. The parameter "s" means strings, and "f" means real values. (The others is that "d" is integer values, "y" is integer values divided by every 3 figures, and "e" is real values with exponential.)

To make a bar graph, check the "Use Bar for X strings graph" button in the Preferences panel. And if you check the "Value on Bar", the values of y data are plotted around bars.

  • Click the Exe button.
  • Calculation results are outputted onto the Graph pane as a graph.
clp_tutorial_4-e.png
  • The calculation results are outputted as a numerical list on the List Pane at the same time.
China
U.S.A.
Saudi Arabia
United Arab Emirates
Australia
Korea, Rep. of
Indonesia
Taiwan
Germany
Thailand
10.79400
16.93400
0.54000
0.70400
1.45300
5.84900
0.85800
5.13100
2.37600
2.66500
13.78400
7.91100
4.32500
3.67200
3.24800
3.17800
2.80700
2.36500
2.14600
1.96400