Good after the help of ederwander. I was able to reach other solutions and manages to leave the code "correct" at first.
After the correction made the code printed what was to be printed 'images are not the same size'. However, another error appeared: value on right hand side of assignment is Undefined. To correct it it was necessary to put a value for the variable C (C = 0) the function C = sub_img(A,B). Thus the code of the function was left:
Then, after using it he sent the message, but I realized that the code would never leave the if because the <= condition would always be true, so I just left <. And for the 'Else' to work, i made a script that changes the size of image B to equal the size of image A and thus show the image with the pixels replaced.
Script (Note that the script has a different task than the function, I just took advantage of even the resize command):
clear; %Clean the variables
A = imread('cameraman.tif'); % Read the first image
B = imread('Circuit.tif'); % Read the second image
imshow(A); pause(3); %Display the first image and wait 3 seconds
imshow(B); pause(3); %Show the second image and wait 3 seconds
B = imresize(B, size(A)); %Changes image size B to image size A
C = imadd(A,B); imshow(C); %Shows the sum 8 Bits
Well, at first my problem was solved, and I would like to ask that if anyone has any book, source, archive to indicate to study programming in Ctave I thank you.
Thank you Ederwander!
Actually, after what you wrote I researched a little better and -= doesn’t exist, the right one would be <=. Probably, as I am using an "old" book, the nomenclature used in it no longer exists. Would you happen to have any nomenclature? Also, with what you have spoken I will post the solution response and the changes I have made :)
– Rafael Sponchiatto