"parameter {0} must be a real scalar" error when using parfor

8 ビュー (過去 30 日間)
Kevin Sun
Kevin Sun 2022 年 4 月 1 日
回答済み: Edric Ellis 2022 年 4 月 1 日
Hello,
In the following parfor loop, I want to add data into a newly created column in a mysql table by going row by row and manually inserting the data using the "update" function. But I end up getting an error, saying that the parameter isn't a scalar. I'm not sure why the error occurs since the beginning and ending values of the loop are both scalars. And if I replace "sizeOfColumn" with a literal constant, it also gives me the same error.
Thank You so much.
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 4 月 1 日
I wonder if you need to use
data = newColumn(i,1);
?

サインインしてコメントする。

採用された回答

Edric Ellis
Edric Ellis 2022 年 4 月 1 日
I think you need to use createConnectionForPool to make your database connection object and have it work correctly inside your parfor loop. (This was introduced in R2019a - if you're using an earlier release, you can probably achieve something pretty similar by using parallel.pool.Constant.)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by