How to find the current address coordinates

7 views (last 30 days)
Hello, in my code i have to check adress of the image in GUI every single loop. If the YData coordiantes are equal to -75, the program should change it to 900. Matlab writes this error: "Error using matlab.graphics.primitive.Image/horzcat. Conversion to matlab.graphics.primitive.Image from logical is not possible."
explanation: DU = array of 4 elements, 4 same images, which has to be moved by Y axis from value 900 to -75. After one of the images reach value -75, it moves back to 900
I'm not sure if this whole code is alright. So if somebody have some advice how to improve it I would be grateful. Here is the part of my code.
for pom1 = 1:1:num_of_cars(4)
set(DU(pom1),'YData',Ymax-1.95);
if [DU(pom1),'YData' == -75]
set(DU(pom1),'YData',Ymax);
num_of_cars(4) = num_of_cars(4) -1;
end
end
  2 Comments
Sriram Tadavarty
Sriram Tadavarty on 20 Mar 2020
The way you used the condition in the if statement seems to be wrong. First access the YData of DU(pom1), assign it a variable and then compare with the value of -75, to make it simple
Miroslav Jiránek
Miroslav Jiránek on 20 Mar 2020
Edited: Miroslav Jiránek on 20 Mar 2020
Thank you, it helps with statement problem. Now MATLAB writes this: "Error using matlab.graphics.GraphicsPlaceholder/set. The name 'YData' is not an accessible property for an instance of class 'matlab.graphics.GraphicsPlaceholder'."
The error have created on this line of code. Can you help me how to write it properly? I have to update 'YData' value in every cycle and decrease the value by 2.5
set(DU(pom1),'YData',(Ymax-2.5))

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!