PLOTTING A SINGLE PLOT ON THE GRAPH
MULTIPLE PLOTS ON THE SAME GRAPH
SUBPLOTS
PIE CHART
OBJECTIVE:
To work on basic graphics, including 2D plots in Scilab.
ALGORITHM:
Define the x-axis and y-axis range.
Use the plot() function to plot the graph.
Provide a title, x-axis, and y-axis labels.
Use multiple plot() commands to overlay different graphs on the same plot.
Populate the figure window with the plot.
Use subplots to divide the figure window into rows or columns and plot multiple graphs.
Generate a pie chart using the pie() command.
SOURCE CODE:
Plotting a Single Plot:
// Defining the x-axis range
X = 0:1:10;
Y = X.^2 - 10.*X + 15;
// Plotting the graph
plot(X, Y);
// Adding title and axis labels
title("X^2 - 10X + 15");
xlabel("X");
ylabel("Y");
Multiple Plots on the Same Graph:
x = 0:1:10;
y = cos(x);
y1 = sin(x);
// Plotting both graphs on the same figure
plot(x, y, x, y1);
// Customizing the plot styles
plot(x, y, 'ys:', x, y1, 'gd--');
Subplots:
f = input('Enter the frequency: ');
a = input('Enter the amplitude: ');
t = 0:0.01:2;
y = a * sin(2 * %pi * f * t);
y1 = a * cos(2 * %pi * f * t);
y2 = t;
// Creating subplots
subplot(3, 1, 1);
plot(t, y);
subplot(3, 1, 2);
plot(t, y1);
subplot(3, 1, 3);
plot(t, y2);
Pie Chart:
// Plotting a pie chart
pie([1 2 5]);
SAMPLE INPUTS & OUTPUTS:
Plotting a Single Plot on the Graph:
// Plot will show a quadratic curve
Multiple Plots on the Same Graph:
// Plot will show cos(x) and sin(x) graphs on the same plot with different styles
Subplots:
// Input:
// Enter the frequency: 2
// Enter the amplitude: 4
Pie Chart:
// Pie chart displaying the values [1, 2, 5]
RESULT:
The two-dimensional graphs are plotted using Scilab commands.
B]
OBJECTIVE:
To develop a program that checks whether a tank is overflowing based on its shape, dimensions, and the rate of flow (civil applications).
ALGORITHM:
Assume the tank is of a specific shape (rectangular, cylindrical, etc.) and define its dimensions.
Calculate the volume of the tank.
For example, for a cylindrical tank:
Vtank=πr2hV_{\text{tank}} = \pi r^2 h where:
rr = radius of the tank (m)
hh = height of the tank (m)
Calculate the volume of liquid: Vliquid=F×tV_{\text{liquid}} = F \times t where:
FF = rate of flow (m³/min)
tt = time taken (min)
Check the overflow condition:
If Vliquid>VtankV_{\text{liquid}} > V_{\text{tank}} → Overflow
If Vliquid<VtankV_{\text{liquid}} < V_{\text{tank}} → Not Overflow
SOURCE CODE:
// User Input
F = input('Enter the Value of Flow Rate: ');
t = input('Enter the time to fill the Tank: ');
r = input('Enter the Radius of the Tank: ');
h = input('Enter the Height of the Tank: ');
// Calculating the volume of the tank
Vtank = %pi * r^2 * h;
disp('Vtank:');
disp(Vtank);
// Calculating the volume of the liquid
Vliquid = F * t;
disp('Vliquid:');
disp(Vliquid);
// Overflow check
if Vliquid > Vtank then
disp('Tank is Overflow');
else
disp('Tank is not Overflow');
end
SAMPLE INPUTS & OUTPUTS:
Input:
Enter the Value of Flow Rate: 10
Enter the time to fill the Tank: 2
Enter the Radius of the Tank: 3
Enter the Height of the Tank: 4
Output:
Vtank:
113.09734
Vliquid:
20
Tank is not Overflow
RESULT:
The program successfully determines if the tank is overflowing or not based on the input values.
C]
OBJECTIVE:
Write a program to determine the structural stability of a given truss.
ALGORITHM:
Assume a definite shape for the truss (e.g., a shape made of straight lines).
Determine the number of members (m) and joints (j) in the structure.
The stability of the truss is calculated using the formula:
m=2j−3m = 2j - 3
Where:
mm = number of members
jj = number of joints
Determine the stability:
If m=2j−3m = 2j - 3 → Stable (Perfect Truss)
If m>2j−3m > 2j - 3 → Indeterminate (Redundant Truss)
If m<2j−3m < 2j - 3 → Unstable (Deficient Truss)
SOURCE CODE:
// User Input
M = input('Enter the Number of Members: ');
J = input('Enter the Number of Joints: ');
// Calculate the required members for stability
N = 2 * J - 3;
// Stability check
if M == N then
disp('The Given Structure is Stable');
elseif M > N then
disp('The Given Structure is Indeterminate');
else
disp('The Given Structure is Unstable');
end
SAMPLE INPUTS & OUTPUTS:
Input (Assuming a Triangle Truss):
Enter the Number of Members: 3
Enter the Number of Joints: 3
Output:
The Given Structure is Stable
RESULT:
The program calculates and displays the stability of the given truss structure based on the number of members and joints.