I am using AutoCAD Civil 3D 2018 and have a .scr file that simply draws a few lines (generated from an excel file), however I am finding that the results are not consistent when I drag the .scr onto a drawing. 50% of the time it looks as I expect, and the rest of the time some of the lines are not displaying, or have incorrect end co-ords.
-color Green pline 603913.8394,7570974.6134 w 15 15 603950.7455,7570959.1881
-color Green pline 603950.7455,7570959.1881 w 15 15 603996.8782,7570939.9065
-color Green pline 603996.8782,7570939.9065 w 15 15 604053.2915,7570916.3279
-color Red pline 604053.2915,7570916.3279 w 15 15 604127.3464,7570885.3759
-color Green pline 604127.3464,7570885.3759 w 15 15 604187.2909,7570860.326
-color Green pline 604187.2909,7570860.326 w 15 15 604240.7861,7570837.9671
-color Green pline 604240.7861,7570837.9671 w 15 15 604277.6908,7570822.5379
-color Green pline 604277.6908,7570822.5379 w 15 15 604314.5966,7570807.1127
-color Green pline 604314.5966,7570807.1127 w 15 15 604388.4088,7570776.2621
-color Green pline 604388.4088,7570776.2621 w 15 15 604473.0531,7570740.8841
-color Green pline 604473.0531,7570740.8841 w 15 15 604532.7468,7570715.9345
-color Green pline 604532.7468,7570715.9345 w 15 15 604582.6623,7570695.0718
-color Green pline 604582.6623,7570695.0718 w 15 15 604661.0878,7570662.293
-color Green pline 604661.0878,7570662.293 w 15 15 604737.4495,7570630.3768
-color Green pline 604737.4495,7570630.3768 w 15 15 604817.9439,7570596.7333
-color Green pline 604817.9439,7570596.7333 w 15 15 604881.4611,7570570.1856
-color Green pline 604881.4611,7570570.1856 w 15 15 604934.0745,7570548.1953
-color Green pline 604934.0745,7570548.1953 w 15 15 605009.7191,7570516.5788
-color Green pline 605009.7191,7570516.5788 w 15 15 605085.3766,7570484.9569
-color Green pline 605085.3766,7570484.9569 w 15 15 605166.7307,7570450.9541
-color Green pline 605166.7307,7570450.9541 w 15 15 605231.2105,7570424.0041
-color Green pline 605231.2105,7570424.0041 w 15 15 605326.3627,7570384.2342
-color Green pline 605326.3627,7570384.2342 w 15 15 605435.2625,7570338.7184
-color Green pline 604227.1343,7570805.3043 w 15 15 604264.039,7570789.8751
-color Green pline 605217.5588,7570391.3413 w 15 15 605312.711,7570351.5714
-color Green pline 604213.4829,7570772.6424 w 15 15 604250.3876,7570757.2132
-color Green pline 605203.9074,7570358.6794 w 15 15 605299.0596,7570318.9095
-color Green pline 603872.8853,7570876.6277 w 15 15 603909.7914,7570861.2024
-color Green pline 604199.8319,7570739.9814 w 15 15 604236.7366,7570724.5522
-color Green pline 605190.2564,7570326.0184 w 15 15 605285.4085,7570286.2485
-color Green pline 604186.1789,7570707.3157 w 15 15 604223.0852,7570691.8903
-color Green pline 605176.605,7570293.3565 w 15 15 605271.7571,7570253.5866
-color Green pline 604172.5291,7570674.6576 w 15 15 604209.4338,7570659.2284
-color Green pline 604209.4338,7570659.2284 w 15 15 604246.3397,7570643.8032
-color Green pline 604246.3397,7570643.8032 w 15 15 604320.1519,7570612.9526
-color Green pline 604320.1519,7570612.9526 w 15 15 604374.6873,7570590.1589
-color Green pline 604374.6873,7570590.1589 w 15 15 604464.4899,7570552.625
-color Green pline 604464.4899,7570552.625 w 15 15 604514.4054,7570531.7623
-color Green pline 604514.4054,7570531.7623 w 15 15 604592.8308,7570498.9835
-color Green pline 604592.8308,7570498.9835 w 15 15 604669.1925,7570467.0673
-color Green pline 604669.1925,7570467.0673 w 15 15 604719.8881,7570445.8786
-color Green pline 604719.8881,7570445.8786 w 15 15 604813.2041,7570406.8761
-color Green pline 604813.2041,7570406.8761 w 15 15 604865.8176,7570384.8858
-color Green pline 604865.8176,7570384.8858 w 15 15 604941.4621,7570353.2693
-color Green pline 604941.4621,7570353.2693 w 15 15 605017.1196,7570321.6475
-color Green pline 605017.1196,7570321.6475 w 15 15 605068.3974,7570300.2154
-color Green pline 605068.3974,7570300.2154 w 15 15 605162.9536,7570260.6946
-color Green pline 605162.9536,7570260.6946 w 15 15 605258.1058,7570220.9247
-color Green pline 604209.434,7570659.228 w 15 15 604277.691,7570822.538
-color Green pline 604161.6941,7570651.3272 w 15 15 604199.5231,7570635.5162
-color Green pline 604941.462,7570353.269 w 15 15 605009.719,7570516.579
-color Green pline 603784.0512,7571028.8598 w 15 15 603890.9216,7571194.1743
-color Green pline 603841.2898,7571004.9363 w 15 15 603912.7505,7571117.3467
-color Green pline 603913.8394,7570974.6134 w 15 15 603920.4434,7571055.513 603886.7386,7571077.4224
-color Cyan pline 603912.7505,7571117.3467 w 15 15 603998.5629,7571061.5656
-color Green pline 604250.473,7570960.456 w 15 15 604341.582,7570912.882 604381.387,7570973.875
-color Red pline 604815.842,7570771.62 w 15 15 604778.78,7570715.084 604860.437,7570661.554
-color Green pline 604778.78,7570715.084 w 15 15 604737.449,7570630.377
-color Green pline 605164.047,7570626.375 w 15 15 605126.893,7570569.902 605209.313,7570515.678 605126.893,7570569.902 605090.261,7570496.644
-color Green pline 605514.134,7570480.162 w 15 15 605476.879,7570423.755 605559.574,7570369.136 605476.879,7570423.755 605440.34,7570350.867
-color Green pline 604127.346,7570885.376 w 15 15 604169.314,7570950.713
-color Cyan pline 605681.391,7573276.081 w 15 15 605764.108,7573402.828
-color Green pline 604881.4611,7570570.1856 w 15 15 604982.8368,7570727.6401
-color Green pline 604817.9439,7570596.7333 w 15 15 604928.3409,7570763.4931
-color Green pline 605098.346,7571023.828 w 15 15 605163.984,7571123.319
-color Green pline 605301.045,7571332.397 w 15 15 605369.575,7571436.936
-color Green pline 605506.637,7571646.015 w 15 15 605575.168,7571750.554
-color Green pline 605713.380,7571958.331 w 15 15 605781.409,7572065.184
-color Green pline 605917.8476,7572273.2909 w 15 15 605978.1289,7572365.2462
-color Green pline 606123.4142,7572586.8699 w 15 15 606191.945,7572691.4093
-color Green pline 606329.0066,7572900.4882 w 15 15 606397.5374,7573005.0277
-color Green pline 606754.5613,7573549.1972 w 15 15 606815.1891,7573642.1293
-color Green pline 606952.9974,7573852.3472 w 15 15 607021.5283,7573956.8868
-color Green pline 607158.59,7574165.9659 w 15 15 607227.1209,7574270.5055
-color Green pline 605231.2105,7570424.0041 w 15 15 605329.3108,7570575.9192
-color Cyan pline 605583.2721,7570960.4254 w 15 15 605652.2076,7571064.7961
-color Green pline 605166.7307,7570450.9541 w 15 15 605277.8033,7570618.2776
-color Green pline 605277.8033,7570618.2776 w 15 15 605376.2123,7570768.0893
-color Green pline 605376.2123,7570768.0893 w 15 15 605444.9153,7570872.5168
-color Green pline 605444.9153,7570872.5168 w 15 15 605513.6178,7570976.9436
-color Green pline 605513.6178,7570976.9436 w 15 15 605582.3199,7571081.3697
-color Green pline 605582.3199,7571081.3697 w 15 15 605664.5694,7571206.3877
-color Green pline 605664.5694,7571206.3877 w 15 15 605719.725,7571290.2233
-color Green pline 605719.725,7571290.2233 w 15 15 605788.428,7571394.6509
-color Green pline 605788.428,7571394.6509 w 15 15 605857.13,7571499.0769
-color Green pline 605857.13,7571499.0769 w 15 15 605925.8331,7571603.5045
-color Green pline 605925.8331,7571603.5045 w 15 15 605993.3653,7571706.1524
-color Green pline 605993.3653,7571706.1524 w 15 15 606063.2382,7571812.3582
-color Green pline 606063.2382,7571812.3582 w 15 15 606131.9402,7571916.7841
-color Green pline 606131.9402,7571916.7841 w 15 15 606200.6433,7572021.2118
-color Green pline 606200.6433,7572021.2118 w 15 15 606269.3452,7572125.6377
-color Green pline 606269.3452,7572125.6377 w 15 15 606352.0457,7572251.3412
I have attached two images showing the differences that I am seeing, the first image is what I expect, the second image shows how it appears when it is not importing correctly.
I can drag it into an empty drawing, it sometimes it will show correctly. If I then delete the lines and drag the .scr file in again it will always show incorrectly.
At first I though it was because I have a few errant spaces at the end of lines, but it doesn't appear so.
Can anyone help me get to the bottom of what is going on here?
Many thanks
Lee
When supplying points to a command prompt either through an AutoCAD Script (.scr) or AutoLISP program (.lsp), the points will be affected by any Object Snap modes active at the time of evaluation.
There are three ways to avoid this:
1. Disable Object Snap
Disable Object Snap entirely prior to running your script (either by toggling F3 [thereby toggling the 16384 bit of the OSMODE system variable], or by storing the current value of the OSMODE system variable and then setting it to 0).
2. "_non" Object Snap Modifier
Precede your point input with the Object Snap modifier _none or _non, instructing AutoCAD to ignore any active Object Snap modes for the next point supplied, e.g.:
-color Green pline _non 603913.8394,7570974.6134 w 15 15 _non 603950.7455,7570959.1881
3. OSNAPCOORD System Variable
Set the OSNAPCOORD system variable to 1.
This system variable determines whether coordinate input at the command-line will be affected by active Object Snap modes:
0 Running object snap settings override keyboard coordinate entry
1 Keyboard entry overrides object snap settings
2 Keyboard entry overrides object snap settings except in scripts
Related
Here is the table -
create table inventoryItem (
itemNum varchar(10) not null
references itemType(itemNum) on delete cascade,
code varchar(20) not null,
qtyInstock float not null,
itemColor varchar(15),
itemSize float,
primary key (itemNum, code)
This is the values -
insert into inventoryItem values ('A0', 'pbk', 30, 'black', 3.0);
insert into inventoryItem values ('B1', 'hbk', 50, 'white', 4.0);
insert into inventoryItem values ('A0', 'hbk', 25, 'green', 4.0);
insert into inventoryItem values ('C2', 'hbk', 20, 'black', 3.0);
insert into inventoryItem values ('C1', 'ebk', 70, 'black', 4.0);
insert into inventoryItem values ('A3', 'pbk', 30, 'black', 2.0);
insert into inventoryItem values ('A2', 'pbk', 50, 'green', 3.0);
insert into inventoryItem values ('A0', 'ebk', 15, 'green', 4.0);
insert into inventoryItem values ('C2', 'pbk', 30, 'black', 3.0);
This is what I have tried -
select itemSize, itemColor, SUM(qtyInstock ) as stock_combination
from inventoryItem
group by itemSize, itemColor;
Further explanation - I want to create a view showing the itemNum itemSize itemColor and a count of how much qtyInstock there is for each instance of a color and size. For example - how much stock is there for a black shirt in size 3 or a white shirt in size 2. I've been lost for hours and have no idea how to go about this. Please help! Thank you to anyone who comments :)
Your query gives what you indicate you are looking for, except you cannot add itemNum and get the correct total as you would need to add it to the group by. (I guess that is what you are discovering.) The solution is the Analytic function version of sum. (See demo)
select itemNum
, itemSize
, itemColor
, qtyInstock
, sum(qtyInstock ) over (partition by itemSize, itemColor) as stock_combination
from inventoryItem
order by itemSize, itemColor, itemNum;
I added the qtyinstock for each as without it the results seem distorted, and perhaps still as it does not include code. But that is easily removed.
Fetch all perm/combination of color and size against itemnum.
Will return 0 as stock qty if that combination does not exist in the inventory -
Actual table -
select * from inventoryitem;
ITEMNUM CODE QTYINSTOCK ITEMCOLOR ITEMSIZE
---------- ----- ---------- --------------- ----------
A0 pbk 30 black 3
B1 hbk 50 white 4
A0 hbk 25 green 4
C2 hbk 20 black 3
C1 ebk 70 black 4
A3 pbk 30 black 2
A2 pbk 50 green 3
A0 ebk 15 green 4
C2 pbk 30 black 3
9 rows selected.
Main Query
select
inum,icol,isize, sum(qnty) as total_qty from
(
with cte as
(
select a.itemnum as inum,b.itemcolor as icol,c.itemsize as isize, 0 as qnty from
(select distinct itemnum from inventoryitem) a,
(select distinct itemcolor from inventoryitem) b,
(select distinct itemsize from inventoryitem) c
)
select cte.inum,cte.icol,cte.isize,cte.qnty from cte
union
select itemnum,itemcolor, itemsize, qtyInstock from inventoryItem
)
group by inum,icol,isize
order by inum,icol;
INUM ICOL ISIZE TOTAL_QTY
---------- --------------- ---------- ----------
A0 black 2 0
A0 black 3 30
A0 black 4 0
A0 green 2 0
A0 green 3 0
A0 green 4 40
A0 white 2 0
A0 white 3 0
A0 white 4 0
A2 black 2 0
A2 black 3 0
A2 black 4 0
A2 green 2 0
A2 green 3 50
A2 green 4 0
A2 white 2 0
A2 white 3 0
A2 white 4 0
A3 black 2 30
A3 black 3 0
A3 black 4 0
A3 green 2 0
A3 green 3 0
A3 green 4 0
A3 white 2 0
A3 white 3 0
A3 white 4 0
B1 black 2 0
B1 black 3 0
B1 black 4 0
B1 green 2 0
B1 green 3 0
B1 green 4 0
B1 white 2 0
B1 white 3 0
B1 white 4 50
C1 black 2 0
C1 black 3 0
C1 black 4 70
C1 green 2 0
C1 green 3 0
C1 green 4 0
C1 white 2 0
C1 white 3 0
C1 white 4 0
C2 black 2 0
C2 black 3 50
C2 black 4 0
C2 green 2 0
C2 green 3 0
C2 green 4 0
C2 white 2 0
C2 white 3 0
C2 white 4 0
54 rows selected.
How to load .csv file and use data in the table to create 2d scatter plot.
The data inside the table is
Name X Y Group Gender Year of Birth Grade
Victor Anderson 627 705 2 Female 2000 6
Jack Scott 808 643 1 Male 2002 4
Sean Robinson 624 627 1 Male 2002 4
William Rodriguez 423 396 1 Female 2004 2
Aaron Kelly 775 181 0 Female 2005 1
Raymond Taylor 433 731 1 Female 2000 1
Alan Foster 635 580 2 Male 2002 4
Charles Watson 884 262 0 Female 2003 3
Lillian Perez 334 190 4 Male 2005 1
Betty Moore 727 524 1 Female 2003 3
Bruce Adams 503 684 0 Male 2001 2
Kathryn Sanchez 284 246 0 Male 2001 2
Chris Hall 189 223 3 Male 2000 6
Eugene Harris 196 220 3 Female 2000 5
Gary Baker 707 559 0 Female 2001 5
Michael Ramirez 299 657 2 Male 2000 1
Walter Smith 400 755 0 Male 2005 5
Ann Murphy 0 895 1 Male 2003 3
Lois Thompson 783 631 1 Female 2003 2
Louis Jones 674 589 1 Female 2003 3
Tammy Bell 828 263 3 Male 2002 4
Carolyn Bailey 557 23 4 Male 2004 2
Larry Campbell 444 627 2 Female 2004 2
To draw a simple scatter plot from the data in the csv we need to:
Ensure X and Y columns can be read as numbers
Normalize or scale the X and Y values to the canvas size
Plot a point for each row at its scaled x and y position
Add labels
For the first item we could add code to clean up X and Y and turn them into numbers. Below I have assumed that X and Y will always be integers and removed white space so we can just call row.getInt()
The data is saved like this:
Name,X,Y,Group,Gender,Year of Birth,Grade
Victor Anderson,627,705,2,Female,2000,6
Jack Scott,808,643,1,Male,2002,4
Notice that extra white space has been removed so that we can call table and row methods without special cleanup code.
Table table;
int xMin;
int yMin;
int xMax;
int yMax;
void setup() {
size(900, 900);
table = loadTable("plot_data.csv", "header");
background(0);
fill(255);
// we get the minimum and maximum values for X and Y so we can scale to our canvas
xMin = getMin(table, "X");
yMin = getMin(table, "Y");
xMax = getMax(table, "X");
yMax = getMax(table, "Y");
}
void draw(){
background(0);
boolean labelDrawn = false;
for (TableRow row : table.rows()) {
int x = row.getInt("X");
// the map function takes our value and maps it to a value that fits on our canvas
float xPos = map(x, xMin, xMax, 0, width);
int y= row.getInt("Y");
float yPos = map(y, yMin, yMax, 0, height);
ellipse(xPos,yPos,10,10);
// Here we put a name label on the plotted data when the mouse is over it
if(dist(mouseX,mouseY,xPos,yPos)<10 && !labelDrawn){
fill(255);
text(row.getString("Name"),mouseX-10,mouseY-10);
labelDrawn = true; // only draw one label at a time
}
}
}
int getMin(Table table, String col){
int min = Integer.MAX_VALUE;
for (TableRow row : table.rows()){
if (row.getInt(col)<min){
min = row.getInt(col);
}
}
return min;
}
int getMax(Table table, String col){
int max = Integer.MIN_VALUE;
for (TableRow row : table.rows()){
if (row.getInt(col)>max){
max = row.getInt(col);
}
}
return max;
}
I am experiencing an erratic behaviour on a heavy lined gnuplot script.
The script intends to plot borderlines. Filledcurve and line styles are used. Also a mono-parametric family of curves are displayed via
plot for [i=1:4] f(x,i) title sprintf("f(x,i) i=%d",i) w l dt 2
I tweeted an example here https://pbs.twimg.com/media/DHbeEgXXkAAV6aS.jpg:large
After this plot I continued introducing Argentina. After a new lines of codes the dashed lines in blue started to behave erratically. Two of them simply vanished.
I started debugging the code and ultimately make use of the set table utility outputing the whole plot into a single file.
I found the for-loop was behaving erraticly. The title line showed that the loop variable i was correctly running from start to end values. However the function f(x,i) was not properly fed with the correct value of i.
On the first iteration the value the loop worked fine and the script plotted f(x,1). On the second iteration the function was correctly fed and displayed f(x,2). But hereafter the function was always fed with i=2 despite title string correctly showed the change in i
The resulting plot was
I would really appreciate a hint helping me to find the bug.
I will now add a few lines of code. The plot command
plot for [i=1:words(europa_cet)] countries u ($1+($2<36?1:0)*15):(mercator($2)) index (word(europa_cet,i)+0) w filledcurve lc rgb colorFondoCET,\
for [i=1:words(paises_wet)] countries u ($1+15+dst*word(dst_wet,i)*15):(mercator($2)) index (word(paises_wet,i)+0) w filledcurve lc rgb colorFondoWET,\
for [i=1:words(southAm)] countries u ($1+(4+dst*word(dstSouthAm,i))*15):(mercator(abs($2))) index int(word(southAm,i)) w filledcurve lc rgb colorFondoGET,\
"magallanes.dat" u (new!=2?$1+dst*15:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
"no_magallanes.dat" u (new!=2?$1:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
for [k=1:5:1] mercator(orto(x,real(b1)+real(k)*real(15.0))) tit sprintf("orto a %02d signo %d",k,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+1*15)) tit sprintf("no loop orto a %02d signo %d",1,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+2*15)) tit sprintf("no loop orto a %02d signo %d",2,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+3*15)) tit sprintf("no loop orto a %02d signo %d",3,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+4*15)) tit sprintf("no loop orto a %02d signo %d",4,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+5*15)) tit sprintf("no loop orto a %02d signo %d",5,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+0*15)) tit sprintf("no loop orto a %02d signo %d",0,Signo) w l lc rgb 'blue' dt 2 lw 3,\
The for-loop (line #6) do not work. Line-by-line calls (lines 7-12) do work.
And the output obtained from set table, first lines of each iteration
# Curve 43 of 104, 100 points FIRST iteration
# Curve title: "orto a 01 signo 1"
# x y type
-22.5 0.874361° i
-21.9697 0.887919° i
-21.4394 0.901287° i
-20.9091 0.914467° i
# Curve 44 of 104, 100 points SECOND iter
# Curve title: "orto a 02 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 45 of 104, 100 points THIRD iter (REPEATS 2nd)
# Curve title: "orto a 03 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 46 of 104, 100 points FOURTH iter (repeats 2nd)
# Curve title: "orto a 04 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 47 of 104, 100 points FIFTH iter (repeats 2nd)
# Curve title: "orto a 05 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
Now I have isolated the problem.
I am pasting again the plot (multi)line. The plot line is run two times one for the left (sunrise) subplot, the second for the right (sunset) subplot in a multiplot environment. They differ in the definition of the function orto and the value for b1.
plot "usa.dat" u (usaBool?($1+6*15):1/0):(mercator($2)) w filledcurve lc rgb colorFondoFET,\
for [i=1:words(europa_cet)] countries u ($1+($2<36?1:0)*15):(mercator($2)) index (word(europa_cet,i)+0) w filledcurve lc rgb colorFondoCET,\
for [i=1:words(paises_wet)] countries u ($1+15+dst*word(dst_wet,i)*15):(mercator($2)) index (word(paises_wet,i)+0) w filledcurve lc rgb colorFondoWET,\
for [i=1:words(southAm)] countries u ($1+(4+dst*word(dstSouthAm,i))*15):(mercator(abs($2))) index int(word(southAm,i)) w filledcurve lc rgb colorFondoGET,\
"magallanes.dat" u (new!=2?$1+dst*15:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
"no_magallanes.dat" u (new!=2?$1:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
mercator(orto(x,b1+1*15)) tit sprintf("no loop orto a %02d signo %d",1,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+2*15)) tit sprintf("no loop orto a %02d signo %d",2,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+3*15)) tit sprintf("no loop orto a %02d signo %d",3,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+4*15)) tit sprintf("no loop orto a %02d signo %d",4,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+5*15)) tit sprintf("no loop orto a %02d signo %d",5,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+0*15)) tit sprintf("no loop orto a %02d signo %d",0,Signo) w l lc rgb 'blue' dt 2 lw 3,\
for [i=1:words(europa_cet)] countries u ($1+($2<36?1:0)*15):(mercator($2)) index (word(europa_cet,i)+0) w l lt 1 lc rgb colorLinea,\
for [i=1:words(paises_wet)] countries u ($1+15*(1+dst*word(dst_wet,i))):(mercator($2)) index (word(paises_wet,i)+0) w l lt 1 lc rgb colorLinea,\
for [i=1:words(southAm)] countries u ($1+(4+dst*word(dstSouthAm,i))*15):(mercator(abs($2))) index int(word(southAm,i)) w l lt 1 lc rgb colorLinea,\
"magallanes.dat" u (new!=2?$1+dst*15:1/0):(mercator($2)) w l lt 1 lc rgb colorLinea,\
"no_magallanes.dat" u (new!=2?$1:1/0):(mercator($2)) w l lt 1 lc rgb colorLinea,\
"usa.dat" u (usaBool?($1+6*15):1/0):(mercator($2)) w l lt 1 lc rgb 'gray50',\
for [i=0:2] "ciudadesChile.dat" u ($2-($6-1+((new==0&i==2)?-1:((new==2&i==1)?1:0))-dst*word(dstSouthAm,i+1))*15):(mercator(abs($1))) index i w p pt 7 lc 1 ps 1.5,\
"ciudadesUsa.dat" u (usaBool?($2+6*15):1/0):(mercator(abs($1))) w p pt 7 lc rgb 'blue' ps 1.5,\
for [k=1:5:1] mercator(orto(x,real(b1)+real(k)*real(15.0))) tit sprintf("orto a %02d signo %d",k,Signo) w l lc rgb 'green' dt 2 lw 10,\
for [i=0:2] "ciudadesChile.dat" u ($2-($6-1+((new==0&i==2)?-1:((new==2&i==1)?1:0))-dst*real(word(dstSouthAm,i+1)+0))*15-$4*.5):(mercator(abs($1+$5*1.1))):(stringcolumn($3)) index i w labels font "Arial-Bold,10" tc rgb word(corporativa,1),\
"ciudadesUsa.dat" u (usaBool?($2+6*15-$4*.5):1/0):(mercator(abs($1+$5*1.1))):3 w labels font "Arial-Bold,10" tc rgb 'blue',\
for [i=1:words(Coastlines)] coastline u 1:(mercator($2)) index (word(Coastlines,i)+0) w l lt 1 lc rgb 'gray50',\
Problem is with the 3rd line from bottom, the one starting with for [i=0:2].
If this line is removed; the loop for [k=1:5:1] operates ok.
If for [k=1:5:1] is placed after 3rd line from bottom, the script operates ok.
If for [k=1:5:1] is placed before 3rd line from bottom, the loop does not operate fine.
The for [i=0:2] prints names of Chilean and Argentinean cities. Column $1 is latitude, $2 is longitude. They are displaced from center throu $4 and $5. The variable i through index controls the country: Argentina=0 Chile=1 RegionMagallanes (Chile)=2. The variable new controls time zone in Chile new=0 is prior to 2015; new=1 is current status, new=2 refers to 2015. Column $6refers to a reference time zone (-3 Argentina and Magallanes, -4 Chile).
The script also controls winter (dst=0) or summer (dst=1) condition.
I have tried and remove pieces (monomials) of the for [i=0:2] line one by one. No success. Even I edited the ciudadesChile.dat file and changed a tab separating $1 and $2 to a space. No success.
I am writing a little game on FPGA in System Verilog and I want to show some small pictures through VGA display. My picture size is 35px X 20px. I converted the picture into three separate arrays (R, G and B values)by using Matlab. I do not know how I can create similar arrays in System Verilog and then call elements in them later. Below is my current code where I have made white dots and red dots. I want to replace these dots with the pictures I mentioned above. Thanks!
begin:RGB_Display
if (missile_On == 1'b1)
begin
Red = 8'h00;
Green = 8'hff;
Blue = 8'h3f;
end
else if (ourMissileOn == 1'b1)
begin
Red = 8'hff;
Green = 8'hff;
Blue = 8'h00;
end
else if ((ball_on == 1'b1))
begin
Red = 8'hff;
Green = 8'hff;
Blue = 8'hff;
end
else if ((enemyAppear == 1'b1))
begin
Red = 8'hff;
Green = 8'h00;
Blue = 8'h2f;
end
else
begin
Red = 8'h3f;
Green = 8'h00;
Blue = 8'h3f; //- DrawX[9:3];
end
end
You can store color information in 24 bit register as
24'hRRGGBB, (RR - Red, GG - Green, BB - Blue) - one pixel
35px x 20px = 700px, 700 * 3 bytes = 2100 bytes
First 35 * 3 = 105 bytes of memory is a first row of image.
Second 35 * 3 = 105 bytes of memory is a second row of image.
....
You can use FPGA Block RAM.
So I have a labeled array (array1) with connected regions of interest (background is all zeros, connected regions are all 1's for the first region, all 2's for the second, 3's for the 3rd etc.) I also have a vector (vector1) of the region labels I find important (ex. 1,6,9). I want to find the locations of these values in the labeled array and then change values in one channel of a separate 3 channel array at the same locations (want to color certain parts of an image green based regions of interest found in another image).
I can use the below code to change all channels, but don't know how to specify (img(y,x,1=0), img(y,x,2=0), img(y,x,3=255)).
for i=1:1:length(vector1)
img(array1==vector1(i))=255;
end
If I understand you correctly, you have a label map of objects - each with an associated ID with 0 as the background. You also have a vector of important IDs and a colour image that is associated with this label map.
You wish to set all locations that have an important ID to 1 colour. I would first create a logical mask where true means that the pixel is important and false otherwise. What I mean by important is that the pixel is either 1, 6 or 9 if we go with your example. You can use bsxfun combined with any to create this mask, then we can use this to index into your image and set the right colour to these locations.
Therefore, do this:
%// Create your logical mask
mask3D = bsxfun(#eq, array1, permute(vector(:), [3 2 1]));
mask = any(mask3D, 3);
%// Set the image pixels to blue at these locations
red = img(:,:,1);
green = img(:,:,2);
blue = img(:,:,3);
red(mask) = 0;
green(mask) = 0;
blue(mask) = 255;
img = cat(3, red, green, blue);
Here's a quick example run. Suppose we have this image with squares:
We can see that there are three squares. Let's change object 1 and object 3 to blue. Before we do that, we need to get a label map:
%// Originally a binary image
im = imread('http://i.stack.imgur.com/DnYQS.png');
%// Get label map
array1 = bwlabel(im);
%// Create colour version out of this binary image
img = 255*uint8(im);
img = cat(3, img, img, img);
array1 is our label map as you have also mentioned in your question and img is the colour version of the input image. Now, vector = [1 3] so we can change those objects. The labelling is such that the top left square is label 1, the middle is label 2 and the bottom right is label 3.
Once I do this and I run the above code, this is the image I get:
You can achieve it in two lines -
%// Create a 3D mask to select the labels [1,6,9] only, as listed in "vector1"
mask = bsxfun(#and,ismember(array1,vector1),ones(1,1,3));
%// Map "img" with "mask" and set them to tuple:[0,0,255] (blue color)
img(mask) = reshape(repmat([0 0 255],nnz(mask)/3,1),[],1)
Sample run -
array1 = %// Input
2 0 1 1 0 6
0 0 1 0 0 6
9 0 0 0 0 6
9 9 0 4 0 0
vector1 = %// Input
1 6 9
img(:,:,1) = %// Input: Before code run
228 19 175 30 192 188
204 23 34 164 149 248
188 204 185 84 189 222
14 241 29 167 60 22
img(:,:,2) =
94 202 197 59 200 136
95 94 53 164 26 24
175 53 100 124 75 104
153 23 141 39 61 27
img(:,:,3) =
29 246 111 48 197 172
201 111 168 68 101 110
75 178 28 204 70 116
154 194 239 125 10 156
img(:,:,1) = %// Output: After code run
228 19 0 0 192 0
204 23 0 164 149 0
0 204 185 84 189 0
0 0 29 167 60 22
img(:,:,2) =
94 202 0 0 200 0
95 94 0 164 26 0
0 53 100 124 75 0
0 0 141 39 61 27
img(:,:,3) =
29 246 255 255 197 255
201 111 255 68 101 255
255 178 28 204 70 255
255 255 239 125 10 156
Notice the positions of the values [1,6,9] in array1 and the corresponding value changes in img1 before and after code runs.