Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6980603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:02:48+00:00 2026-05-27T18:02:48+00:00

I have the following code which is a graphic rendering of the movement of

  • 0

I have the following code which is a graphic rendering of the movement of a satellite around the Earth.

function ex
global state;
fh = figure('Menu','none','Toolbar','none','Units','characters');
hPanAni = uipanel('parent',fh,'Units','characters','Position',...
    [22.6 10.4 53 23],'title','Controls','FontSize',11,...
    'FontAngle','italic','FontWeight','bold');
hIniAni = uicontrol(hPanAni,'Style','pushbutton','Units','normalized',...
    'Position',[0.14 0.75 0.5 0.12],'String','Spin',...
    'FontSize',10,'Callback',@hIniAniCallback);
hFinAni = uicontrol(hPanAni,'Style','pushbutton','Units','normalized',...
    'Position',[0.14 0.5 0.5 0.12],'String','Stop',...
    'FontSize',10,'Callback',@hFinAniCallback);
hResetAni = uicontrol(hPanAni,'Style','pushbutton','Units','normalized',...
    'Position',[0.14 0.25 0.5 0.12],'String','Reset',...
    'FontSize',10,'Callback',@hResetAniCallback);
hPantSim = uipanel('Parent',fh,'Units','characters',...
    'Position',[107.87 8 157.447 42],'BorderType','none','title',...
    'Screen','FontSize',11,'FontAngle','italic',...
    'FontWeight','bold');
hPantSimInt = uipanel('Parent',hPantSim,'Units','normalized','Position',...
    [0 0 1 1],'BorderType','line','BackgroundColor','black');
ah4 = axes('Parent',hPantSimInt,'Units','normalized','Position',...
    [0 0 1 1],'Color','none','Visible','off','DataAspectRatio',...
    [1 1 1],'NextPlot','add');
rotate3d(ah4);
hgrot = hgtransform('Parent',ah4);
T1 = 0:pi/100:2*pi;
Y = zeros(numel(T1),3);
Y(:,1) = 7000*cos(T1);
Y(:,2) = 7000*sin(T1);
xmin = min(Y(:,1));
ymin = min(Y(:,2));
zmin  = min(Y(:,3));
xmax  = max(Y(:,1));
ymax  = max(Y(:,2));
zmax  = max(Y(:,3));
Resf = 6378;
xmin2 = min(xmin,-Resf);
xmax2  = max(xmax,Resf);
ymin2 = min(ymin,-Resf);
ymax2  = max(ymax,Resf);
zmin2  = min(zmin,-Resf);
zmax2  = max(zmax,Resf);
set(ah4,'XLim',[xmin2 xmax2],'YLim',[ymin2 ymax2],'ZLim',[zmin2 zmax2]);
maptext = imread('tierra.jpg');
[X_im, map] = rgb2ind(maptext,128);
[x_esf,y_esf,z_esf] = sphere(50);
x_esf = Resf*x_esf;
y_esf = Resf*y_esf;
z_esf = Resf*z_esf;
props.FaceColor= 'texture';
props.EdgeColor = 'none';
props.Parent = hgrot;
props.Cdata = flipud(X_im); % it is necesary to do this for getting the 
% appropiate image on the sphere
surface(x_esf,y_esf,z_esf,props);
colormap(map);
axis equal vis3d;
view(3);
az = 0;
Fin = numel(T1);
k = 2;
ind_ini = 0;
state = 0;
handles.tray = zeros(1,Fin);
handles.psat = line('parent',ah4,'XData',Y(1,1), 'YData',Y(1,2),...
    'ZData',Y(1,3),'Marker','o', 'MarkerSize',10,'MarkerFaceColor','b');
       function hIniAniCallback(hObject,evt)
            if (ind_ini == 1)
              return;  
            end
            ind_ini = 1;
            state = 0;
            while (k<Fin)
            az = az + 0.01745329252;
            set(hgrot,'Matrix',makehgtform('zrotate',az));
            handles.tray(k) = line([Y(k-1,1) Y(k,1)],[Y(k-1,2) Y(k,2)],...
                [Y(k-1,3) Y(k,3)],...
        'Color','red','LineWidth',3);
            set(handles.psat,'XData',Y(k,1),'YData',Y(k,2),'ZData',Y(k,3));
            pause(0.02); 
            k = k + 1,

            if (state == 1)
                state = 0;
                break;
            end
            end 
       end

    function hFinAniCallback(hObject,evt)
        ind_ini = 0;
        state = 1;
    end
 function hResetAniCallback(hObject,evt)
    set([handles.tray,handles.psat],'Visible','off');
    k = 2;
    ind_ini = 0;
    state = 1;
    az = 0;
    set(hgrot,'Matrix',makehgtform('zrotate',az));
    handles.psat = line('parent',ah4,'XData',Y(1,1), 'YData',Y(1,2),...
    'ZData',Y(1,3),'Marker','o', 'MarkerSize',10,'MarkerFaceColor','b');
end

end

However, when I copy it to my main program I get the following error message:

??? Error using ==> surface
Invalid object handle

Error in ==> simorbiv8v3>hIniPropCallback at 1911
surface(x_esf,y_esf,z_esf,props);

??? Error while evaluating uicontrol Callback

EDIT: After some proofs, I have checked that ishandle(props.Parent) is false. As props.Parent = hgrot, the problem source is this hgtransform variable. It is declared as global one in the main program so there should not be problems then. I do not understand what is wrong with hgrot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:02:49+00:00Added an answer on May 27, 2026 at 6:02 pm

    I suspect this is for a Matlab GUI?

    If so you need to pass the handles variable to the script, normally matlab passes eventdata and hObject as well as a standard procedure for all functions, callbacks and etc.

    function ex(hObject, eventdata, handles)
    

    And don’t forget to update the GUI data to close the function.

    guidata(hObject,handles);
    

    I think all your nested functions that use the handles structure are going to require this as well.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following code which switches some fullscreen-background-images (fadeOut, fadeIn). setInterval(function() { var
I have following code which works for radio buttons but need to be changed
I want to know is below code correct ? I have following code which
I have the following code which definitely returns a proper data result if I
I have the following code which is working, I was wondering if this can
I have the following code which is used to upload large files (~6MB) to
I have the following code which is fine if I give invalid parameters (though,
I have the following code which will generate two pdf files containing plots to
I have the following code which utilises Guava's Files.readLines() method: List<String> strings = Lists.newArrayList();
I have the following code which takes List of boolean as a parameter then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.