Borrar filtros
Borrar filtros

How To Sort Excel Sheet By Address In GUI

2 visualizaciones (últimos 30 días)
Mark M
Mark M el 23 de Jul. de 2017
Comentada: Mark M el 25 de Jul. de 2017
Hello,
I have an excel sheet that I have imported into MATLAB using the import tool. The Excel sheet has multiple types of cells, both numbers, characters, and both characters and numbers. (e.g. one column is either 'hip' or 'gable', another is simply numbers from 0-9, and a third is a combination of characters and numbers like '1000 Main St.')
In my code, I have each street listed in a listbox, and I've written "if" statements for each Value in the listbox. I can sort into a table the way I want with the column that only has numbers, but for mixed char/numbers and solely char, I cannot do it.
Here is a snippet of the code I have that works for the numbers (0-9):
%Import dataset in the GUI Opening Function. import1 is the function the Import Data created.
imported = import1('ExcelFile.XLSX','Complete Excel File DATA',1,713);
handles.Table = imported;
%listbox code
a = get(handles.SortRating,'Value');
T = handles.Table;
if (a==1)
%Table Creation for Ratings = 0
Rating0 = T.Rating<1;
names0 = {'Rating', 'Var2', 'Var3' , ....};
T0 = T(Rating0,names0);
table0 = table2cell(T0);
finaltable0 = [T.Properties.VariableNames; table0];
set(handles.uitable1,'Data', finaltable0 );
end
The above code displays all the data from the excel file for all Ratings = 0 in the excel sheet. As I said previously, I need this for char. and char. w/ numbers. Your help is appreciated!
Also, as a side note - Would this work better as a table or a structure? I have imported it as a table because it was what I know best.
  4 comentarios
Jan
Jan el 25 de Jul. de 2017
@Mark M: "Cite"? This function is published in the FileExchange and covered by the BSD license. Keep the license file beside the function. Or what do you mean by "citing"?
I do not understand the problem of picking "subsections". How are these sections defined?
Mark M
Mark M el 25 de Jul. de 2017
@Jan Simon,
Here is an example of my data. In this example, I want to allow the user to choose the data they see based on the street name. So if the listbox has two choices, 'Main St.' and '2nd Ave.', and the user chooses 'Main St.', I want the table to populate with all the data from homes on Main St.
'34 MAIN ST' '66 MAIN ST' '99 MAIN ST' '70 MAIN ST' '74 MAIN ST' '22 2ND AVE' '8 2ND AVE' '5 2ND AVE'
I have tried to it in a way similar to that above, i.e. an if statement for each 'Value' of the listbox (1 being Main St, 2 being 2nd Ave, etc.) and then inside the if statement, the code needed to sort out and display just that subsection. In my above code, since the T.Rating is numerical, I can use normal operators like < and ==, but since this is both numbers and characters, I cannot use those operators.
Have I explained my problem a little better?

Iniciar sesión para comentar.

Respuestas (0)

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by