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.

回答(1 个)

Kaustubha Govind
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 个评论
partha das
partha das 2011-6-22
if UITABLE is not supported in matlab then why it is showing results for any m*n matrix excluding 1*n or m*1 matrix???
please reply
Walter Roberson
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 CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by