Exporting a matrix to Microsoft Access: Error using database/

Click For Summary
SUMMARY

The issue of exporting a matrix "Q" from MATLAB R2014b to Microsoft Access was resolved by adjusting the database settings. Initially, only the first row of the matrix was inserted, leading to a general error during the operation. The solution involved enabling the "Сoncordance of Element are allowed" setting in Microsoft Access, which corrected the insertion process and allowed all three rows of the matrix to be successfully exported.

PREREQUISITES
  • Familiarity with MATLAB R2014b programming
  • Understanding of Microsoft Access database settings
  • Knowledge of matrix manipulation in MATLAB
  • Experience with database connection and insertion commands in MATLAB
NEXT STEPS
  • Research how to configure Microsoft Access settings for data import
  • Learn about MATLAB's database toolbox for advanced data handling
  • Explore error handling techniques in MATLAB database operations
  • Investigate best practices for matrix data export to databases
USEFUL FOR

MATLAB developers, database administrators, and anyone involved in data export processes between MATLAB and Microsoft Access.

Margarett
Messages
3
Reaction score
0
Hello! Below is the code for the following task:
  • matrix "Q" with a dimension of 3*2 was obtained using a matrix of cells "A";
  • then the matrix "Q" is exported to Microsoft Access with the same dimension (3 rows, 2 columns).
(!) The difficulty is that only the first row of the matrix is written to Microsoft Access (of the three available) and then an error message is displayed:
  • Error using database/insert (line 213) General error
  • Error in test_matlab (line 22) insert(conn, 'Rtu', colnames, Q);
(?) Tell me, please, how is it necessary to add / correct the code in order to record all three rows of the matrix in Microsoft Access?
  • I use MATLAB version R2014b.
  • Below there is an archive with files.
  • I am using the MATLAB version R2014b.
  • Below is an archive with files.
[Код]
Q=[];
A={1, [3 5 8]} % array of cells

for j=1:2 % matrix column index
for i=1:3 % matrix row index
if j==1
Q(i,j)=A{1,j};
else
Q(i,j)=A{1,j}(1,i);
end
end
end

Q

conn = database('QWERT', '', '');
colnames = {'u1', 'u2'};

insert(conn, 'Rtu', colnames, Q);
close(conn);
[/ код]
 

Attachments

  • access.jpg
    access.jpg
    33.1 KB · Views: 410
Physics news on Phys.org
I found a solution to this problem.
The question is closed.
 
If someone is interested to know the cause of errors, the reason is as follows.
The code was correct.
The problem was in the settings of Microsoft Access.
It was necessary to specify in the settings of Microsoft Access "Сoncordance of Element are allowed".
Before this was specified in the settings "Сoncordance of Element are not allowed".
In result, the program began to work correctly after changing the settings.
 

Similar threads

  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K