Matlab code to java using shared library

3 views (last 30 days)
Hi! I have a very special problem in matlab and I really hope you can help me. I try to run my matlab script with shared library compiler on computers without matlab. I have followed the introduction: https://de.mathworks.com/help/compiler_sdk/gs/create-a-java-application-with-matlab-code.html exactly but I have the problem that my function requires an image, not a number! Here is my code:
if true
function [F,C]=factorImage3a(d_pp)
%name='/Users/name/archive/speichel.dcm';
%info=dicominfo(name);
matrix=128;
nf=2;
ni=100;
%d_pp=dicomread(h);
%--------------------------------------------------------------------------
is=matrix; % image size
np=is*is; % number of pixels
%--------------------------------------------------------------------------
% convert images to vectors
v=zeros(np,1);
d=zeros(np,ni);
for i=1:ni
v(:)=d_pp(:,:,:,i);
d(:,i)=v;
end
clear d_pp h
%--------------------------------------------------------------------------
% PRINCIPAL COMPONENT ANALYSIS - for variants and details cf Matlab help
%[coeff,score,latent]=pca(zscore(d));
%[coeff,score,latent]=pca(d);
%[coeff,score]=princomp(zscore(d));
[cf,P]=princomp(d); %(:,4:13));
%--------------------------------------------------------------------------
%[fc,~,~,~,F]=factoran(d,nf,'rotate','varimax','scores','wls','maxit',5000);
[fc,~,~,~,F]=factoran(d,nf,'rotate','varimax','scores','wls','maxit',7000);
% rotate - for details cf Matlab help
% none
% equamax
% orthomax
% parsimax
% pattern
% procrustes
% promax
% quartimax
% varimax
% scores - for details cf Matlab help
% wls or Bartlett
% regression or Thomson
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% extraction of factor curves
m=max(F);
for i=1:nf
F(:,i)=F(:,i)/m(i);
end
%C=d(:,4:13)'*F/(F'*F);
C=d'*F/(F'*F);
%--------------------------------------------------------------------------
%figure % figure 3
a=zeros(is);
for i=1:nf
%a(:)=F(:,i);
end
for i=(nf+1):2*nf
%subplot(2,nf,i);
%plot(C(:,i-nf),'o-');
%grid on
%set(gca,'XLim',[0,11],'YLim',[0,35]);
%ts=['FACTOR CURVE ',int2str(i-2)];
%title(ts,'FontSize',12);
end
%--------------------------------------------------------------------------
end
end
When I try to run it I get the error: Exception: java.lang.NumberFormatException: For input string: "untitled.fig" Exception in thread "main" java.lang.NullPointerException at getmagic1.main(getmagic1.java:36)
Can you help me to adapt the code so I can run the file? Thanks a lot!

Answers (0)

Categories

Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!