Unable to perform assignment because the left and right sides have a different number of elements in cell array
4 ビュー (過去 30 日間)
古いコメントを表示
Hello everybody,
Currently I have a bidimensional cell array which size is 200 * 2. I'm trying to append an element to the last position in some moment of my program, but however I'm unable to do so because I have this error "Unable to perform assignment because the left and right sides have a different number of elements".
I'm trying to append the data with this command: app.quizImages(end + 1) = {app.currentImageId, app.currentImagePath};
Where app.quizImages is the cell array, app.currentImageId is a number and app.currentImagePath is a string.
When I display the cell array this is the content that i'm getting (I have not putted everything since the size is 200 * 2)
{[ 1]} {'1.jpg' }
{[ 2]} {'10.jpg' }
{[ 3]} {'11.jpg' }
{[ 4]} {'12.jpg' }
{[ 5]} {'120.jpg'}
{[ 6]} {'121.jpg'}
And when I display the content I want to append this is what I'm getting
{[64]} {'21.jpg'}
Do you see any error in what I'm doing? I don't understand what I'm doing wrong and I have tried to fix it a long time already
Thank you!
0 件のコメント
採用された回答
Rashed Mohammed
2021 年 3 月 19 日
Hi Marcos,
Since you want to append two items - app.currentImageId and app.currentImagePath to the end of cell array, you should be specifying the entire row instead of just a single cell. Below is the code to resolve your issue
app.quizImages(end+1,:) = {app.currentImageId, app.currentImagePath};
Hope this helps.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!