add a moving image over a plotted trajectory
Show older comments
x = 0:pi/100:2*pi;
y = sin(x);
plot(x, y);
%i want my image to move in this way
alpaca = 'alpaca.png';
[I,map,transparency] = imread(alpaca);
%i have this code to remove the background of my image
%i tried using image sc but i couldnt get it to work
%thank you!
3 Comments
Isobel Leikis
on 8 May 2022
Sumit
on 11 Oct 2023
Please check attachment. according to that i want multiple image (stationary) along trajectory. How it can be done
DGM
on 11 Oct 2023
Accepted Answer
More Answers (1)
Voss
on 7 May 2022
Something like this?
x = 0:pi/100:2*pi;
y = sin(x);
figure();
plot(x, y);
hold on
xlim([0 2*pi]);
ylim([-1 1]);
I = imread('alpaca.png');
im = image(I,'XData',[0 1],'YData',[0 1]);
for ii = 1:numel(x)
set(im,'XData',x(ii)+[-0.5 0.5],'YData',y(ii)+[-0.5 0.5]);
drawnow();
end
5 Comments
ss
on 30 Jun 2022
hi, the same problem, the image does not display when i copied your code
did you khow why please?
Voss
on 1 Jul 2022
Do you have the image file alpaca.png?
Try doing
clear image
and then running it again.
That is, you may have a variable called image in your workspace that needs to be cleared before you can use the image function.
ss
on 5 Jul 2022
yes it works! thank you a lot
Categories
Find more on Image Arithmetic 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!