showing the error' ??? Object belongs to an incompatible Java class. Error in ==> try2 at 7 set(t,'Data', eg1);'
1 次查看(过去 30 天)
显示 更早的评论
i was trying to get an matrix out put in matlab7.5 using the prog
eg=[1 2 3 4] %[m,n]= size(eg);
f = figure('Position', [100 100 752 350]); t = uitable('Parent', f, 'Position', [100 100 700 200]); eg1= num2cell(eg); set(t,'Data', eg1);
it is showing the error ??? Object belongs to an incompatible Java class.
Error in ==> try2 at 7 set(t,'Data', eg1); but it showing every matrix of order m*n, but showing the error in case of matrix of order 1*n or m*1. please help me so that i can get the matrix of order m*1. thank you in advanced.
0 个评论
回答(1 个)
Kaustubha Govind
2011-6-22
I'm not sure if UITABLE was documented/supported fully in MATLAB 7.5 - I am able to run your code without any errors on MATLAB 7.12 (R2011a).
For MATLAB 7.5, you could try converting your data to a Java object array and then set it on the uitable's Data:
egJ = javaArray('java.lang.Object', 1,4) ;
for m = 1:length(eg)
egJ(1,m) = java.lang.Double(eg(m));
end
set(t, 'Data', egJ);
2 个评论
Walter Roberson
2011-6-22
"unsupported" can mean that it exists but is not promised to work for any given case. You got lucky that it worked at all for you.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!