Importing image from VBA and display it in a matlab meshgrid.

Hello,
I use COM component to execute a m file from VBA which display a meshgrid in a matlab figure. But while this figure is open, I cannot acces to my VBA program to load an other image. My goal is the meshgrid refresh as I load a new image, and then, the news images come from a camera.
VBA code:
Public Sub MFile()
Dim MatLab As Object
Dim Result As String
Dim a As String
Set MatLab = CreateObject("MatLab.Desktop.Application")
Result = MatLab.Execute("cd 'G:\Documents and Settings\admin\Mes documents\Sebastien\script plot3D'")
Result = MatLab.Execute("plot3D")
UserForm1.TextBox1.Text = Result
End Sub
Mfile:
function Plot3D(~)
close all
%image=ImIN;
path='G:\Documents and Settings\admin\Mes documents\Sebastien\ImagesSeb\image1.tif';
image = imread(path);
Z=rgb2gray(image);
[n,m]=size(Z);
x = linspace(1,n,size(Z,2)); %# x-coordinates for columns of Z
y = linspace(1,m,size(Z,1)); %# y-coordinates for rows of Z
[X,Y] = meshgrid(x,y); %# Create meshes for x and y
C = image;%imread('peppers.png'); %# Load RGB image
figure
h = mesh(X,Y,Z,flipdim(C,1),... %# Plot surface (flips rows of C, if needed)
'FaceColor','texturemap',...
'EdgeColor','none');
pause
Thanks.

Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Asked:

on 29 Nov 2011

Community Treasure Hunt

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

Start Hunting!