Creating a MATLAB Matrix from ISP Connections

In summary, you can use the "importdata" function to import your txt or xls file and then use the "cellstr" function to manipulate the data and create a new matrix with the connections. Good luck with your programming!
  • #1
Stoccardo
1
0
hello everyone!
perhaps I am right here. i need help with programming MATLAB. i ve got a txt (or alternatively a xls) file. stored in it are internet service provider connections. i want to import this file and form a matrice. in this initial matrice each connection should be shown (a connection is city1 --> city2). below is a _small_ excerpt of the file i have.
help is really appreciated.
/Stoccardo

Rk City1 City2 Provider
84 Ealing, UnitedKingdom Ilford, UnitedKingdom Brit.Telecom
85 Ealing, UnitedKingdom Glasgow, UnitedKingdom Brit.Telecom
86 Kingston, UnitedKingdom Ilford, UnitedKingdom Brit.Telecom
87 Bletchley, UnitedKingdom Milan, Italy Brit.Telecom
88 Ealing, UnitedKingdom Santa Clara, CA Brit.Telecom
89 Ealing, UnitedKingdom Dallas, TX Brit.Telecom
90 Paris, France London, UnitedKingdom Colt
91 London, UnitedKingdom Caracas, Venezuela Colt
92 Paris, France Berlin, Germany Colt
93 London, UnitedKingdom Dublin, Ireland Colt
94 London, UnitedKingdom Barcelona, Spain Colt
 
Physics news on Phys.org
  • #2
Look up textread, fscanf and xlsread :)
 
  • #3
Hello Stoccardo,

I can help you with importing and forming a matrix in MATLAB for your internet service provider connections. First, you will need to use the "importdata" function to import your txt or xls file into MATLAB as a matrix. This function will automatically detect the delimiter used in your file (in this case, it seems to be a tab) and create a matrix with the data.

Next, you will need to use the "cellstr" function to convert the first two columns (City1 and City2) into cell arrays. This will allow you to manipulate the data more easily and create a new matrix with the connections.

Here is an example code:

% Import the data
data = importdata('yourfile.txt');

% Convert the first two columns into cell arrays
city1 = cellstr(data(:,1));
city2 = cellstr(data(:,2));

% Create a new matrix with the connections
connections = [city1 city2];

% Display the connections
disp(connections);

I hope this helps! Let me know if you have any further questions.
 

Related to Creating a MATLAB Matrix from ISP Connections

1. How do I create a MATLAB matrix from ISP connections?

To create a MATLAB matrix from ISP connections, you will need to first establish a connection between your MATLAB software and your ISP. This can typically be done by using the 'webread' function in MATLAB, which allows you to access data from a URL. Once you have established a connection, you can use the data from your ISP to create a matrix in MATLAB.

2. Can I create a matrix from multiple ISP connections?

Yes, you can create a matrix from multiple ISP connections by using the same 'webread' function for each connection, and then combining the data into a single matrix using the 'horzcat' or 'vertcat' function in MATLAB.

3. How do I handle missing data or errors in my ISP connections when creating a matrix?

If your ISP connections contain missing data or errors, it is important to handle them properly to ensure accurate results. One way to do this is by using the 'try...catch' statement in MATLAB, which allows you to try a certain code and catch any errors that may occur. You can then use the 'NaN' function to replace any missing data in your matrix.

4. Is there a limit to the size of the matrix I can create from ISP connections?

Yes, there is a limit to the size of the matrix you can create from ISP connections. This limit is dependent on the memory and processing power of your computer, as well as the amount of data available from your ISP. It is important to consider these factors when creating a matrix from ISP connections to avoid any performance issues.

5. Can I manipulate the data from my ISP connections before creating a matrix in MATLAB?

Yes, you can manipulate the data from your ISP connections before creating a matrix in MATLAB. This can be done by using various functions and operations in MATLAB, such as filtering, sorting, or converting data types. It is important to familiarize yourself with these functions to effectively manipulate your data before creating a matrix.

Back
Top