How do I solve this error?: Matrix out of range for deletion
Can someone help me to figure out why I am out of range for deletion with this? This code was first used with data that had multiple values in the matrix (i.e. "carbclay" was a matrix with 4 values), but now I’m only doing it with one value, so maybe that’s why it’s not working? I have gotten a lot of help with this so I don’t quite understand it fully, forgive my lack of knowledge when it comes to calling things the right name, hope someone can understand what’s wrong:( The goal of the code is to be able to leave off legend entries if any of the data that I want to plot is missing from my table.
carbclay=[rocktypes(1)]; missingdata1=[];
np = 0;
hp = [];
legtxt = {};
i = find(string(TAllData.gen_rock_type)==carbclay);
if any([sum(isnan(TAllData.a_b(i)))==length(i),sum(isnan(TAllData.temp(i)))==length(i)])
missingdata1=[missingdata1,i];
else hp(end+1) = scatter(TAllData.temp(i),TAllData.a_b(i),120,c1,’filled’,’o’,’MarkerFaceAlpha’,0.7);
legtxt{end+1} = carbclay{1};
end
carbclay(missingdata1)=”; %The error happens here for some reason, and then the legend does not show up
legend(hp,legtxt,’Location’,’northeastoutside’);
Error Message:
Matrix index is out of range for deletion.
Error in ScriptForPlots_RFD (line 1507)
carbclay(missingdata1)=”;Can someone help me to figure out why I am out of range for deletion with this? This code was first used with data that had multiple values in the matrix (i.e. "carbclay" was a matrix with 4 values), but now I’m only doing it with one value, so maybe that’s why it’s not working? I have gotten a lot of help with this so I don’t quite understand it fully, forgive my lack of knowledge when it comes to calling things the right name, hope someone can understand what’s wrong:( The goal of the code is to be able to leave off legend entries if any of the data that I want to plot is missing from my table.
carbclay=[rocktypes(1)]; missingdata1=[];
np = 0;
hp = [];
legtxt = {};
i = find(string(TAllData.gen_rock_type)==carbclay);
if any([sum(isnan(TAllData.a_b(i)))==length(i),sum(isnan(TAllData.temp(i)))==length(i)])
missingdata1=[missingdata1,i];
else hp(end+1) = scatter(TAllData.temp(i),TAllData.a_b(i),120,c1,’filled’,’o’,’MarkerFaceAlpha’,0.7);
legtxt{end+1} = carbclay{1};
end
carbclay(missingdata1)=”; %The error happens here for some reason, and then the legend does not show up
legend(hp,legtxt,’Location’,’northeastoutside’);
Error Message:
Matrix index is out of range for deletion.
Error in ScriptForPlots_RFD (line 1507)
carbclay(missingdata1)=”; Can someone help me to figure out why I am out of range for deletion with this? This code was first used with data that had multiple values in the matrix (i.e. "carbclay" was a matrix with 4 values), but now I’m only doing it with one value, so maybe that’s why it’s not working? I have gotten a lot of help with this so I don’t quite understand it fully, forgive my lack of knowledge when it comes to calling things the right name, hope someone can understand what’s wrong:( The goal of the code is to be able to leave off legend entries if any of the data that I want to plot is missing from my table.
carbclay=[rocktypes(1)]; missingdata1=[];
np = 0;
hp = [];
legtxt = {};
i = find(string(TAllData.gen_rock_type)==carbclay);
if any([sum(isnan(TAllData.a_b(i)))==length(i),sum(isnan(TAllData.temp(i)))==length(i)])
missingdata1=[missingdata1,i];
else hp(end+1) = scatter(TAllData.temp(i),TAllData.a_b(i),120,c1,’filled’,’o’,’MarkerFaceAlpha’,0.7);
legtxt{end+1} = carbclay{1};
end
carbclay(missingdata1)=”; %The error happens here for some reason, and then the legend does not show up
legend(hp,legtxt,’Location’,’northeastoutside’);
Error Message:
Matrix index is out of range for deletion.
Error in ScriptForPlots_RFD (line 1507)
carbclay(missingdata1)=”; matrix, table, legend MATLAB Answers — New Questions