Error using tabular/nu​mArguments​FromSubscr​ipt

2 visualizzazioni (ultimi 30 giorni)
Sergio Gonzalez
Sergio Gonzalez il 16 Mar 2021
Risposto: Tejas il 17 Lug 2025
I have created a loop that looks for the number "X" and returns the rows where it is located
for rowcount = 1:size(Summarytable,1)
if strcmp(Summarytable.year{rowcount},year)
rowsforyear = [rowsforyear,rowcount];
end
end
Error using tabular/numArgumentsFromSubscript (line 111)
Brace indexing is not supported for variables of this type.
Error in export_PSA_year_summary (line 92)
if strcmp(Summarytable.year{rowcount},year)
I don't understand how to solve the problem. On Matlab 2019 are working but on 2020 version not work.
How can i fix it?

Risposte (1)

Tejas
Tejas il 17 Lug 2025
I am assuming that the variable "Summarytable" belongs to the class "table".
The above error message might be due to usage of curly braces for indexing in this section of code:
if strcmp(Summarytable.year{rowcount},year)
To resolve the issue, use parenthesis instead, as recommended in this example: https://www.mathworks.com/help/matlab/ref/table.html#mw_7b054635-18c5-4076-bd1a-28cc2ef6dd5d .
if strcmp(Summarytable.year(rowcount),year)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by