利用com实现vc++与matlab混编c程序如下if(FAILED(CoInitialize(NULL))) { AfxMessageBox("unable to initialize COM"); } Ical *st=NULL; HRESULT hr=CoCreateInstance(CLSID_cal,NULL,CLSCTX_ALL,IID_Ical,(void **)&st);matlab程序如下function out=simulation(m_blaser,m_ndistant)if(strcmp(m_blaser,'m_blaser1')) t=0.01:0.01:30; t=3000.*t; T1=exp(-0.5*10^(-4)).*t; alpha=(1/m_ndistant).*log(T1);endif(strcmp(m_blaser,'m_blaser2')) t=0.01:0.01:30; t=3000.*t; T2=exp(-5*10^(-4)).*t; alpha=(1/m_ndistant).*log(T2);endif(strcmp(m_blaser,'m_blaser3')) t=0.01:0.01:30; t=3000.*t; T3=exp(-10*10^(-4)).*t; alpha=(1/m_ndistant).*log(T3);endplot(t,alpha)out=mean(alpha);编译后出现错误:error C2664: 'simulation' : cannot convert parameter 2 from 'int *' to 'struct tagVARIANT *'求高手帮忙解决,小弟是刚好需要用到com才开始学的,连入门都还没。。。急!!!!所有积分都压上了,虽然不多。
c程序补充如下 if(FAILED(CoInitialize(NULL))) { AfxMessageBox("unable to initialize COM"); } Ical *st=NULL; HRESULT hr=CoCreateInstance(CLSID_cal,NULL,CLSCTX_ALL,IID_Ical,(void **)&st); if(SUCCEEDED(hr)) { if(m_blaser1) { st->simulation(1,&out,m_blaser1,m_ndistance1); st->Release(); AfxMessageBox("succeed"); Info+="m_blaser1"; }
|