필터 지우기
필터 지우기

how do i load database in m file?

조회 수: 11 (최근 30일)
Rya
Rya 2017년 5월 25일
댓글: Rya 2017년 5월 31일
how do i load database in m file? so that i could match value of variable with values stored in database field? A quick reply will be really appreciated. thank you

채택된 답변

Walter Roberson
Walter Roberson 2017년 5월 25일
You cannot meaningfully load an SQL database into a MATLAB session. What you can do is make queries against a database to retrieve the information stored there. For information about that, see https://www.mathworks.com/help/database/import-data.html
... However, it is questionable as to why you bothered to store your license plate related information in an SQL server, unless you have a lot of license plate information. containers.Map() would probably be sufficient for your purposes.
  댓글 수: 6
Walter Roberson
Walter Roberson 2017년 5월 30일
In that case you should be able to use something like
[~, ~, raw] = csvread('YourFile.csv');
Then
[tf, idx] = ismember(lower(DetectedLicensePlate), lower(raw(:,1)) );
if ~tf
fprintf('Plate not registered, or OCR did not work well enough\n')
else
fprintf('Plate found at row #%d of database\n', idx);
end
Rya
Rya 2017년 5월 31일
i dont have any file with csv extension, and what is tf, and idx?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

MathReallyWorks
MathReallyWorks 2017년 5월 25일
Hello Rya,
Use this to load the database in your workspace:
1. Go to home
2. Click on Import Data
3. Select your file. (I'll suggest to keep data in excel sheet)
4. A window will appear
5. click on import selection and remember the names of variable(Use that variable name in code given below)
Now, use this code to check whether the particular number is present in database or not.
clc;
clear all
X = [1 323 2 44 3 66 77 88 2 1 2 3 34 56 78 5 7 4 44 28]; %Sample DataBase
%Remove above line and replace X by variable name of your database
b = input('enter the number you want to check:');
n = find(X==b);
A = isempty(X(n));
if A==1
disp('The number is not present in database');
else
disp('The number is present in database');
end
  댓글 수: 2
Rya
Rya 2017년 5월 30일
Rya
Rya 2017년 5월 30일
It doesn't work

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by