0
Question for plotting 2D

Hello, Im a very beginner in scilab.

I would like to ask how to plot2d like this diagram below.

I can apply the formula when the temperature raise, but in the melting peroid,

how do I plot this peroid.

Thanks.


Scilab 05-04-17, 11:03 a.m. chanyau1125
0

Dear chanyau,

Since this the plot consist of multiple line segments, we cannot plot it with a single plot2d function. Here is how I did it

x1=0:0.5:1; //taking arbitrary x axis data as the x axis in plot above is blank

y1=-40:20:0; // -40 to 0

plot2d(x1,y1)


x2 =1:2;

y2= repmat(0,1,2);

plot2d(x2,y2) //the horizontal line at 0


x3 =2:4;

y3 = 0:50:100;

plot2d(x3,y3); //0 to 100


x4=4:10;

y4=repmat(100,1,7);

plot2d(x4,y4) //horizontal line at 100


x5=1:0.5:11;

y5=100:20:140;

plot2d(x1,y1,nax=[-1,0,-1,8])  //100 to 140,the -1 in nax removes the ticks in x axis as it is in the plot above


xtitle("Temperature vs Heat absorbed", "Heat Absorbed","Temperature") //title and x & y labels

05-04-17, 11:54 a.m. G_John
x1=0:180;
y1=0.0117.*x1^2
plot2d(x1,y1)

x2=180:780;
y2=repmat(379.08,180,780)
plot2d(x2,y2)
I tried like yours, but it saying 
Warning: Syntax "vector ^ scalar" is obsolete. It will be removed in Scilab 6.0.
  Use "vector .^ scalar" instead.
plot2d(x2,y2)
              !--error 999 
plot2d: Wrong size for input arguments: Incompatible sizes.
at line      15 of exec file called by :    
exec('C:\Users\kwuncchan6\Desktop\x1y1.sce', -1)

05-04-17, 12:25 p.m. chanyau1125

Login to add comment


0


05-04-17, 12:17 p.m. chanyau1125
Dear chanyau,
Here are some modifications to your code
x1^2 :since x1 is a vector, it is better to use x .^ 2.  ( .^ operator is for vectors and just ^ is for scalar)

x2=180:780 : this statement creates a vector with gap of 1. For example, 0:6 makes [0 1 2 3 4 5 6]. whereas 0:2:6 makes [0 2 4 6]. In your case I 60 as the gap. Hence x2=180:60:780

repmat=repmat function repeats its first input into a matrix of the dimensions of the next two inputs.repmat(2, 1 ,5) makes matrix of 2 of dimension 1x5 i.e. [2 2 2 2 2]. In your case since x2 has 11 elements,plot2d function requires that both x and y have the same dimensions. Therefore I have modified that line to y2=repmat(379.08,1,11)

The modified code is given below
x1=0:180;
y1=0.0117.*x1.^2;
plot2d(x1,y1)

x2=180:60:780;
y2=repmat(379.08,1,11)
plot2d(x2,y2)

05-04-17, 12:36 p.m. G_John

Thank your so so much.

Lastly, I would like to plot a reverse curve like x1,y1 at x3=780,960

but I dont have a reverse formula of y1=0.0117 x^2

Can I copy the x1,y1 curve and reverse it ?

thanks.


x1=0:180;
y1=0.0117.*x1.^2
plot2d(x1,y1)

x2=180:60:780;
y2=repmat(379,1,11)
plot2d(x2,y2)



05-04-17, 12:57 p.m. chanyau1125
I do not understand what you mean by reverse formula. I hope this meets your need
x3=780:960;
y3=plot2d(x3,-y1)

05-04-17, 1:10 p.m. G_John

sorry for bad explanation

I would to plot a curve like below at 780 to 960

which is a curve from  y=379 to 0

and I think it seems like the y1 curve

therefore I ask a reverse curve of y1


05-04-17, 1:18 p.m. chanyau1125
Dear chanyua,
That requires mathematical operations like transformation and mirroring which is out of scope here. For a reference,here is a link

05-04-17, 2 p.m. G_John

Login to add comment


0
If you search in our Textbook Companion page, you will see many different ways of drawing a 2D plot. An easy way to draw the plot you have asked is given in the example available at http://cloud.scilab.in/index.php?eid=5360#. You can access such examples for many different commands from this TBC Code Search page: http://scilab.in/tbc_solr_search
05-04-17, 2:57 p.m. kannan


0
%Note: range t from - to + t=-2:0.1:2; %x=-3:0.1:3; y=2.*(exp((t.^(2))/2)); plot(t,y,'linewidth',3); I can't upload pictures here!! geometry dash is very useful in aligning right angles.
25-10-22, 1:15 p.m. valenzuela


Log-in to answer to this question.