Trending February 2024 # A Quick Glance Of Matlab Scripts With Examples # Suggested March 2024 # Top 3 Popular

You are reading the article A Quick Glance Of Matlab Scripts With Examples updated in February 2024 on the website Eastwest.edu.vn. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 A Quick Glance Of Matlab Scripts With Examples

Introduction to Matlab Scripts

Matlab Script is a sequence of various commands, which are most likely used to represent some program and are executed in the same way as a program or single command in Matlab command window. The script is created using ‘edit’ command in Matlab. Variables that are created in a script can be accessed from the Matlab command window until we clear them or terminate the session. To run our script, we must save it in current directory, or in a directory saved on Matlab path. Matlab scripts must be saved as ‘.m’ extension and this is the reason they are referred as “M-files”.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Examples of Matlab Scripts

Given below are the examples:

Example #1

In this example we will create a script that will generate 5000 random numbers between 0 and 100. We will also create a histogram for all these numbers.

Below are the steps that we will follow for this example:

Use ‘edit’ command to create new script.

Write the code for generating 5000 random numbers and drawing a histogram.

Code:

edit myHisto

[Using the ‘edit’ command to create the script ‘myHisto’]

[Initializing the number of columns]

[Initializing the number of columns]

Row = 1;

[Initializing the number of rows]

[Initializing the number of rows]

Bins = Col/100;

[Defining the Bins for the histogram]

[Defining the Bins for the histogram]

rng(now);

[Using the ‘Random number generator’ to create random values]

[Using the ‘Random number generator’ to create random values]

A = 100*rand(Row, Col);

histogram(A, Bins)

[Drawing the histogram using above values] [Save this file as .m extension. Please keep in mind that the name of the file must be same as the name of the script, which is ‘myHisto’ in our example]

[Drawing the histogram using above values] [Save this file as .m extension. Please keep in mind that the name of the file must be same as the name of the script, which is ‘myHisto’ in our example]

Next, we need to call this script. This is done by typing the name of the script in the command window as below:

myHisto

[Calling the script created in the command window]

[Calling the script created in the command window]

Input:

histogram(A, Bins)

[Please notice that in the above figure, the name of the file is same as the name of the script]

[Please notice that in the above figure, the name of the file is same as the name of the script]

Output:

As we can see in the output, we have obtained a histogram of random values as expected by us.

Example #2

In this example we will create a script that will be used to find the integration of a function.

Below are the steps that we will follow for this example:

Use ‘edit’ command to create the new script.

Write the code for computing the integration using ‘integral’ function.

Code:

edit myIntegral

[Using the ‘edit’ command to create the script ‘myIntegral’]

[Using the ‘edit’ command to create the script ‘myIntegral’]

syms x

[Initializing the local variable ‘x’]

[Initializing the local variable ‘x’]

Fx = @(x) 5*x.^3

[Creating the polynomial function of degree 3]

[Creating the polynomial function of degree 3]

A = integral (Fx, 0, 3)

[Passing the input function& the required limits] [Save this file as .m extension and keep the name as ‘myIntegral’] [Mathematically, the integral of 5*x ^3, between the limits 0 to 3 is 101.25]

[Passing the input function& the required limits] [Save this file as .m extension and keep the name as ‘myIntegral’] [Mathematically, the integral of 5*x ^3, between the limits 0 to 3 is 101.25]

Next, we need to call this script. This is done by typing the name of the script in the command window as below:

myIntegral

[Calling the script created in the command window]

[Calling the script created in the command window]

Input:

A = integral (Fx, 0, 3)

As we can see in the output, we have obtained integration of our function by calling the script.

Example #3

In this example we will create a script that will be used to draw a sphere.

Below are the steps that we will follow for this example:

Use ‘edit’ command to create the new script.

Write the code for drawing a sphere of radius ‘Rad’.

Code:

edit drawSphere

[Using the ‘edit’ command to create the script ‘drawSphere’] [a, b, c] = sphere; [Creating unit sphere]

[Using the ‘edit’ command to create the script ‘drawSphere’] [a, b, c] = sphere; [Creating unit sphere]

Rad = 2;

[Initializing the radius]

[Initializing the radius]

surf(a * Rad, b * Rad, c * Rad)

[Adjusting the dimensions & creating the plot]

[Adjusting the dimensions & creating the plot]

axis equal

[Making the scale common for each axis] [Save this file as .m extension and keep the name as ‘drawSphere’]

[Making the scale common for each axis] [Save this file as .m extension and keep the name as ‘drawSphere’]

Next, we will call this script. This is done by typing the name of the script in the command window as below:

drawSphere

[Calling the script created in the command window]

[Calling the script created in the command window]

Input:

axis equal

Output:

Example #4

In this example will plot a sine wave and a cos wave in the same plot using script.

Below are the steps that we will follow for this example:

Use ‘edit’ command to create the new script.

Write the code for creating the waves and plot them.

Code:

edit drawWaves

[Using the ‘edit’ command to create the script ‘drawWaves’]

[Using the ‘edit’ command to create the script ‘drawWaves’]

A = linspace (-pi, 2*pi);

[Initializing the interval]

[Initializing the interval]

Y = sin(A);

[Creating the sine wave]

[Creating the sine wave]

Z = cos(A);

[Creating the cos wave]

[Creating the cos wave]

T = plot(A, Y, A, Z);

[Creating the plot] [Save this file as .m extension and keep the name as ‘drawWaves’]

[Creating the plot] [Save this file as .m extension and keep the name as ‘drawWaves’]

Next, we will call this script. This is done by typing the name of the script in the command window as below:

drawWaves

[Calling the script created in the command window]

[Calling the script created in the command window]

Input:

T = plot(A, Y, A, Z);

Output:

As we can see in the output, we have obtained a plot containing sine and cos waves by calling the script.

Conclusion

Scripts in Matlab consist of a sequence of commands which we use as a program by calling them from a separate command window. While creating a script, we must save it as .m extension and keep the file name the same as the name of the script.

Recommended Articles

This is a guide to Matlab Scripts. Here we discuss the introduction to Matlab Scripts along with the examples for better understanding. You may also have a look at the following articles to learn more –

You're reading A Quick Glance Of Matlab Scripts With Examples

Quick Glance On Matlab Vpa With Examples

Introduction to Matlab vpa

The following article provides an outline for Matlab vpa. Matlab variable precision arithmetic is used in calculations where large numbers are involved (as input or output), and the primary focus is on precision and not the speed of computation. The high precision for these long numbers is achieved by algorithms that group these numbers into smaller parts for calculation.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

For example, the mathematical ‘pi’ has more than 31 Trillion digits, but we usually use 3.14 as its value. However, some of our calculations might require more digits to be involved, and this is where vpa (variable precision arithmetic) comes in handy.

Syntax:

vpa (a)

vpa (a, n)

The vpa (a) is used to compute the elements of the input ‘a’ till ‘n’ significant digits.

By default, the value of significant digits is 32 for the vpa function.

Examples of Matlab vpa

Given below examples shows how to use vpa in Matlab:

Example #1

In this example, we will use vpa to perform a non-terminating division. First, we will compute the result using the normal division in Matlab, and then we will use vpa to understand the utility of vpa clearly.

For this example, we will divide 2 by 3, which will give us a non-terminating output.

Code without using vpa:

[Using ‘double’ as the data type to ensure that the decimal part is displayed in the output] [Displaying the output (without vpa)]

Input:

Output:

Code using vpa:

[Initializing symbolic input] [Declaring the input] [Displaying the output using vpa]

Input:

Output:

If we compare the 2 outputs above, we will notice that the first one has 4 significant digits, whereas the second one has 32, and thus the second one, which uses vpa, provides more precision.

Example #2

Next, we will use vpa to compute the value of a mathematical expression.

For this example, we will add two non-terminating numbers and will see the difference in precision while using vpa. Here the output will also be a non-terminating number.

Code without using vpa:

[Declaring the first input, using ‘double’ as the data type to ensure that the decimal part is displayed in the output] [Declaring the second input] [Adding the 2 inputs (without using vpa)]

Input:

Output:

Code using vpa:

[Initializing symbolic input] [Declaring the first input] [Declaring the second input] [Adding the 2 inputs using vpa]

Input:

Output:

As we can see in the two output above, we have obtained 5 significant digits without using the vpa, whereas 32 significant digits while using the vpa, resulting in more precision.

Example #3

Next, we will use vpa to compute the value of a mathematical expression involving square root.

For this example, we will add 2 numbers with non-terminating and non-repeating square roots and will see the difference in precision while using vpa. Here also, the output will be a non-terminating number.

Code without using vpa:

[Declaring the first input variable and using the sqrt function to compute the square root] [Declaring the second input variable and using the sqrt function to compute the square root] [Adding the 2 inputs (without using vpa)]

Input:

Output:

[Initializing symbolic input] [Declaring the first input variable] [Declaring the second input variable] [Adding the 2 inputs using vpa]

Input:

Output:

As we can see in the two outputs obtained above, we have obtained 5 significant digits without using the vpa, whereas 32 significant digits while using the vpa, resulting in more precision.

In the above 3 examples, we got 32 significant digits as the output; however, we can get more or less than 32 digits if required. For this, we will pass the required number of digits as the second argument to the vpa function.

Example #4

In this example, we will learn how to get more than 32 digits, say 50, in the output.

Code:

[Initializing symbolic input] [Declaring the first input, and using vpa to get 50 significant digits] [Declaring the second input] [Adding the 2 inputs using vpa and again passing 50 as the second argument to get 50 significant digits]

Input:

Output:

As we can see in the output, we now have 50 significant digits as expected by us.

Conclusion

The vpa is used in Matlab to increase precision in the output. We can control the number of significant digits in the output using the input argument; by default, this number is 32. Using vpa can affect the performance of a program, as the focus is on precision.

Recommended Articles

This is a guide to Matlab vpa. Here we discuss the introduction and the examples of Matlab vpa for a better understanding. You may also have a look at the following articles to learn more –

A Quick Glance Of Postgresql Count With Examples

Introduction to Postgresql Count

There are many aggregate functions present in the PostgreSQL database. One of the aggregate function that is used to find the row count is the COUNT() aggregate function. This function counts the total number of rows according to the query statement and clauses. When it is used on a particular column, then only non-NULL values are considered. In this article, we will see how does COUNT() function works with *, a particular column for nun-NULL values, DISTINCT keyword, GROUP BY clause, and HAVING clause with the help of examples. We will begin studying and understanding the working of the COUNT() function by learning its syntax. In this topic, we are going to learn about Postgresql Count.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Syntax

FROM tableName [WHERE conditionalStatements];

The count function can accept different parameters. It can be passed with either “*” to count all the rows in the result set or with a column name preceded by the distinct or all keyword, to count distinct or all values in that specific column. By default, it is an ALL keyword when mentioned in a particular columnName. Using the DISTINCT keyword limits the result set to unique values within the specified columns. The table name specifies the table from which we want to retrieve the result and determine the row counts. ConditionalStatements are the conditions you wish to apply in the where clause and are optional.

Example of Postgresql Count

Let us begin by connecting to out PostgreSQL database and open the psql terminal command- prompt using the following statements –

sudo su – postgres psql

The above queries will result in the access to Postgres command-prompt as follows –

Now let us create one table and insert values in it.

CREATE TABLE educba (technical_id serial PRIMARY KEY,technology_name VARCHAR (255) NOT NULL,course_Duration INTEGER,starting_date DATE NOT NULL DEFAULT CURRENT_DATE,department VARCHAR(100));

Firing the above query in our psql terminal command prompt will result in the following output –

Let us insert the value in the educba table without mentioning the starting_date column’s value while inserting.

INSERT INTO educba(technology_name, course_duration, starting_date, department) VALUES ('psql',35,'2024-04-07','Database');

This gives the following output –

Let’s insert some more entries –

INSERT     INTO      educba(technology_name,     course_duration,     department)     VALUES ('mysql',40,'Database'); INSERT     INTO      educba(technology_name,     course_duration,     department)     VALUES ('javascript',30,'scripting language'); INSERT INTO educba(technology_name, course_duration, department) VALUES ('java',35,'server- side language'); INSERT     INTO      educba(technology_name,     course_duration,     department)     VALUES ('Angular',35,'Client-side language');

That results in the following output –

Let us now check the contents of our table educba by firing the following SELECT command –

SELECT * FROM educba;

That gives the following output –

Let us retrieve the row count of the educba table using the COUNT() function. The query statement will be as follows –

SELECT COUNT(*) FROM educba;

That results in the following output –

Now, let us count the rows with 35 days of course_duration using the following query statement –

SELECT COUNT(*) FROM educba WHERE course_duration=35;

That results in the following output result –

As there are three rows with psql, java, and angular as technology_name that have a course duration of 35 days, we got the row count as 3.

Using DISTINCT keyword

You can use the DISTINCT keyword in the SELECT clause whenever you want to get the unique row count of the particular column field. For example, suppose that we want to retrieve

How many departments are used in the educba table then we can mention DISTINCT(department) in the SELECT clause using the following query statement –

SELECT COUNT(DISTINCT(department)) FROM educba;

That results in the following output-

Using GROUP BY clause

Now, let us retrieve the count of rows grouped according to the course_duration. Following will be the query statement that will be used to get the count of records grouped based on the course_duration column –

SELECT COUNT(*),course_duration FROM educba GROUP BY course_duration;

Those output will be as follows –

As three technologies are having a course duration of 35 and one technology counts with 40 and 30 days duration each, the above output is correct. But we cannot know which technologies are considered in that count. To do so, we can use GROUP_CONCAT() function.

Using string_agg function

The above query just retrieved the count of technologies grouped on course_duration used in the educba table. If we want the list of those technologies, then we can use the string_agg() function to get the comma-separated list of those technologies in the following way –

SELECT  COUNT(technology_name)  as  technology_count,  course_duration   as duration_in_days ,string_agg(technology_name,',') as list_of_technologies FROM educba GROUP BY course_duration;

The output of the above query statement is as follows –

Retrieving column count alter table educba add column temp_null_col varchar default null;

And for verifying the records of educba, we will fire the following command –

SELECT * from educba;

Whose output is as follows –

update educba set temp_null_col='temp' where department='Database';

Whose output is as follows –

SELECT * from educba;

That results in the following output –

Now, let us get the count of the column temp_null_col using the following query –

select count(temp_null_col) from educba;

Whose output is as follows –

Considering only non-null values, the count of rows in the column temp_null_col is 2.

Conclusion

We can use the COUNT() aggregate function in PostgreSQL to get the count of the number of rows of the particular query statement. Internally, the query fires to obtain the result set containing all the rows that meet the condition. To determine the count value, the system performs calculations on the retrieved result set. Additionally, you can apply the COUNT() function to specific columns to retrieve the count of non-null values within those columns.

It can also be used with the GROUP BY clause to get the count of grouped results. To fetch the count of unique values, the DISTINCT() function can be used in the SELECT clause. Additionally, the string_agg() function can be employed to obtain a list of column values from other columns, excluding the column used for counting, providing a list of values considered in that count.

Recommended Articles

We hope that this EDUCBA information on “Postgresql Count” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

A Quick Glance Of C++ Pop() With Programming Examples

Introduction to C++ pop()

Web development, programming languages, Software testing & others

Syntax

The syntax flow of the C++ pop() is as follows :

Name_of_Stack.pop()

Name_of_stack: This represents the stack where the elements are present in an order.

Pop: It is the method name that is called to decrease the size of the stack by one as the entire stack is arranged with the elements.

Parameter: The function doesn’t consider any of the parameters into consideration. Rather, it just deletes the last element present in the stack and makes the size of the stack decreased by one, as the last element is the first element to get deleted.

There is no return value for the C++ pop() function, as it is used just for the removal of elements from the stack in a fashion where the last element is the first element to get removed from the stack. Therefore, the return type of the function is null.

How pop() method works in C++?

pop() method is a method as part of the stack data structure whose main aim is to remove the topmost element from the stack in some fashion. The element gets removed from the stack container, and due to the removal of that element, the stack size gets decreased by one. The complexity of  pop() method is also constant as there is no major change that is performed on the stack data structure except for the fact of removing elements from the top of the stack.

Even the element removal happens from the top of the stack, which does not provide more changes in the values of the stack. The modification of elements within the stack does not make much difference, but it does perform very minute differences like it performs the deletion operation, which is used for reflecting the change at the top of the stack with the element i.e. it changes the topmost position of the element of stack by reflecting the top position of the stack but the element within the stack gets decreased by the size of one.

It can be considered and said that the Last in the first out fashion of element removal gels well with the pop() method. Pop() method in C++ also falls for some errors and exceptions like it will give an error if the value is passed as an argument from the method, although it is not a conventional way of making the function fed with arguments if this is performed then it will definitely throw an error.

Also, sometimes it is not guaranteed for the fact that there will be some exceptions or that the parameter will throw some exceptions with the values for the method. Stack push and stack pop are two completely opposite methods that support the stack as a data structure, but then the entire pop() function, which deals with Last in first out order, does not support the stack push method, which follows for FIFO(First in First out method).

Also, the complexity of element retrieval is not that much because it just removes elements from the stack rather making the entire set of elements in the stack merged with unwanted elements as well. There is not much difference in terms of complexity for the pop() method as a function because it just makes changes and manipulation on top of the element.

Examples to Implement C++ pop()

Below are the examples mentioned :

Example #1

This program demonstrates the usage of the C++ pop() method, which removes the topmost element from the stack, as shown in the output.

Code:

int main() { for(int h=0; h<6; h++) n_stck.push(h); std::cout <<“Pop_Out_Elements : “; while (!n_stck.empty () ) { std::cout <<” ” << n_stck.top(); n_stck.pop(); } std::cout<<“n”; return 0; }

Example #2

This program demonstrates the C++ pop() method, where the top elements get removed from the stack, as shown in the output.

Code:

using namespace std; int main() { m_stck.push(5); m_stck.push(8); m_stck.push(7); m_stck.push(2); m_stck.push(11); m_stck.push(10); m_stck.pop(); m_stck.pop(); m_stck.pop(); while (!m_stck.empty()) { cout << ‘ ‘ << m_stck.top(); m_stck.pop(); } }

Output:

Example #3

This program demonstrates the C++ pop() and push() both function as part of the standard library function, which is used for removing the elements from the stack, as shown in the output.

Code:

using namespace std; int main() { int p = 0; m_stck.push(12); m_stck.push(10); m_stck.push(3); m_stck.push(1); m_stck.push(9); m_stck.push(14); while (!m_stck.empty()) { m_stck.pop(); p++; } cout << p; }

Output:

Conclusion

The C++ pop() method is part of the stack data structure, which contains the method in the standard library of the stack and lets programmers use these functionalities with ease and flexibility. This provides the programmers an insight into the content and data of the stack, which helps in maintaining the proper and appropriate elements by removing the unessential elements from the stack.

Recommended Articles

This is a guide to C++ pop(). Here we discuss an introduction to C++ pop(), syntax, parameters, and how does it work with examples. You can also go through our other related articles to learn more –

A Quick History Of Neural Networks

This article is part of the Data Science Blogathon.

Introduction

Neural networks are ubiquitous right now. Organizations are splurging money on hardware and talent to ensure they can build the most complex neural networks and bring out the best deep learning solutions.

Although Deep Learning is a fairly old subset of machine learning, it didn’t get its due recognition until the early 2010s. Today, it has taken the world by storm and captured public attention in a way that very few algorithms have managed to accomplish.

In this article, I wanted to take a slightly different approach to neural networks and understand how they came to be. This is the story of the origin of neural networks!

The earliest reported work in the field of Neural Networks began in the 1940s, with Warren McCulloch and Walter Pitts attempting a simple neural network with electrical circuits.

The below image shows an MCP Neuron. If you studied High School physics, you’ll recognize that this looks quite similar to a simple NOR Gate.

The paper demonstrated basic thought with the help of signals, and how decisions were made by transforming the inputs provided.

                                                                McCulloch-Pitts Neuron

McCulloch and Pitts’ paper provided a way to describe brain functions in abstract terms, and showed that simple elements connected in a neural network can have immense computational power.

Despite its groundbreaking implications, the paper went virtually unnoticed till about 6 years later, when Donald Hebb (image below) published a paper that reinforced that neural pathways strengthen each time they are used.

                                                                  Donald Hebb (Father of Neuropsychology)                                                                               Photo Credit: researchgate.net

Keep in mind that computing was still in its nascent stage at that point, with IBM coming out with its first PC (The IBM 5150) in 1981.

Fast forward to the ’90s, a lot of research into artificial neural networks had already been published. Rosenblatt had created the first perceptron in the 1950s. The backpropagation algorithm was successfully implemented at the Bell Labs in 1989 by Yann LeCun. By the 1990s, the US Postal Service had already deployed LeCun’s model for reading ZIP Codes on envelopes.

The LSTM (Long Short Term Memory) as we know it today was coined back in 1997.

If so much groundwork had already been laid down by the 90’s, why did it take until 2012 to leverage neural network for deep learning tasks?

Hardware and the Rise of the Internet

The last two decades have seen rapid strides in the field of Hardware and the Internet. In the 1990s, the IBM PC had a RAM of 16KB. In the 2010s, the average RAM of PC’s used to be around 4GB!

Nowadays, we can train a small-sized model on our computers, which would have been unfathomable in the ’90s.

The Gaming market also played a significant role in this revolution, with companies like NVIDIA and AMD investing heavily in supercomputing to deliver a high-end virtual experience.

With the growth of the internet, creating and distributing datasets for machine learning tasks became that much easier.

It has become rather easy to collect images from Google or mine text from Wikipedia to train and build Deep Learning Models.

The 2010’s: Our Era of Deep Learning

ImageNet: In 2009, the beginning of the modern deep learning era, Stanford’s Fei-Fei Li created ImageNet, a large visual dataset that has been lauded as the project that spawned the AI Revolution in the world.

Back in 2006, Li was a new professor at the University of Illinois – Urbana Champaign. Her colleagues would continuously talk about coming up with new algorithms that would make better decisions. She, however, saw the flaw in their plan.

The best algorithm wouldn’t run well if it was trained on a dataset that reflected the real world. ImageNet consisted of more than 14 million images across more than 20,000 categories, and to date, remains the cornerstone in Object Recognition Technology.

Public Competitions: In 2009, Netflix held an open competition called Netflix Prize, to predict user ratings for films. On September 21, 2009, a prize of 1 million USD was awarded to BellKor’s Pragmatic Chaos team which beat Netflix’s own algorithm by 10.06%.

Started in 2010, Kaggle is a platform that hosts machine learning competitions open to everyone across the globe. It has allowed researchers, engineers, and homegrown coders to push the envelope in solving complex data tasks.

Prior to the AI Boom, the investment in artificial intelligence was around 20 million USD. By 2014, this investment had grown twenty-fold, with market leaders like Google, Facebook, and Amazon allocating funds to further research into AI products of the future. This new wave of investments led to increased hiring in deep learning from a few hundred to tens of thousands.

Despite its slow beginnings, Deep Learning has become an inescapable part of our lives. From Netflix and YouTube recommendations to language translation engines, from facial recognition and medical diagnosing to self-driving cars, there is no sphere that Deep Learning has not touched.

AI is not our future, it is our present, and it’s just getting started!

Related

Examples Of Sql Port With Explanation

Introduction of SQL Port

In networking, a port is a docking endpoint through which communication is established between the server and client and information flows from a program in the user’s computer to servers on the internet. In SQL also, we have multiple types of database engines such as SQL SERVER, POSTGRESQL, MYSQL etc. which communicate through ports. When a port number is used in combination with an IP address, it determines the direction of flow of information. These ports are part of the Transport Layer and are usually of two types TCP(Transmission Control Protocol) and User Datagram Protocol(UDP). Each port in the SQL database engine has a unique service to perform. For example, TCP 1433 is the default port number in SQL Server, and it is used for managing SQL instances over the network. While PostgreSQL uses TCP 5432 to perform the same task.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

In this article, we will attempt to illustrate how you can check the port number on which your SQL database engine is running, how it can be changed, and a few other things. For this article, we have written examples for PostgreSQL and SQL Server. But once you get the hang of it in any database engine, it’s quite intuitive in others.

Examples of SQL Port

Following are the examples are given below:

Example #1

How to find the port number to which the PostgreSQL database server is listening and change it to a new port number?

We can find out the port number and other details of the port to which the server is listening using a SELECT statement on the pg_settings table as shown below.

SELECT name, setting, category , short_desc FROM pg_settings WHERE name = 'port';

In this example, we have just fetched the port number, category, and description from the table. You can use SELECT * instead and fetch all the details. Now, observe the port number ‘5432’ and the short_desc corresponding to it. TCP port 5432 is the default to which the server listens to. For the curious ones, you can find more details on networking in SQL database server from the postmaster file or use the query given below.

select * from pg_settings where context = 'postmaster';

You will set some output, as shown in the image above.

Changing Port Number to A Different Port Number.

Step 1: Open SQL shell and write the following commands in the shell.

locate postgresql.conf

port = 5433 listen_addresses='*'

The above mentioned command will change the port number to ‘5433’ corresponding to all the IP addresses. You can get specific here by mentioning a specific IP address instead of ‘*’.

Example #2

How to find the port number to which the MS SQL server is listening and how to change it?

In SQL server, we have SQL Server configuration manager where we have all the configuration details saved. If you want to see what port number your database server is listening to follow the following steps then.

Step 1: Open SQL Server configuration manager. (If you are not able to find it directly look for it in the search tab)

 Step 2: Once you have opened your SQL Server configuration manager, open SQL Server Network Configuration as shown in the image below.

Step 5: If you wish to change the TCP port number then provide a new port number in the blank space corresponding to IP address 127.0.0.1, this corresponds to your localhost. You may make a change in IPALL if you want to change it for all the addresses.

And you are done changing the port number.

Conclusion

In this post, we have covered how to find the port number to which the SQL database server is listening to and have also learned to change it to a specific port number. A SQL port is basically a TCP port that acts as the endpoint of communication between your local computer and database server on the network.

Recommended Articles

We hope that this EDUCBA information on “SQL Port” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Update the detailed information about A Quick Glance Of Matlab Scripts With Examples on the Eastwest.edu.vn website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!