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

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

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)

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)

x3=780:960;

y3=plot2d(x3,-y1)

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

That requires mathematical operations like transformation and mirroring which is out of scope here. For a reference,here is a link

Login to add comment

`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.chanyau1125Login to add comment