Can imtranslate and squeeze be combined to one code line?

Can you combine squeeze and imtranslate to one line? If so, how?

4 Comments

Hi Stelios, could you provide some more information regarding what you're trying to achieve? In my opinion, some code might help people understand better.
The normal imtranslate command is
imtranslate(im,[translation_vector]).
If I write
imtranslate(squeeze(im,[translation_vector]))
I get an error of too many input arguments. Can they be combined or not?
@Stelios: You are not a newcomer in this forum. Please remember to post the complete error message, not just a part of it.
I'm convinced, the message reveals the detail, that you provide 2 input arguments to the squeeze command, but this accepts 1 only. You can find the cause of such problems using the debugger. Type this in the command window:
dbstop if error
Now run the code again until it stops at the error. Check the sizes of the variables and run the code in pieces:
size(translation_vector)
class(translation_vector)
size(im)
class(im)
% This is done as standard, but does not reveal the problem yet...
% But this does:
c = squeeze(im, translation_vector)
Using the debugger is more efficient than asking the forum.
By the way, there is no need for square brackets around a vector. See Why not use square brackets
The specific error is the whole error. There is no any other valuable part to consider of the specific error, apart the line code where is spotted, which is irrelevant to our case.
I assume you are right that squeeze accepts only 1 input

Sign in to comment.

Answers (1)

As long as you only need the first output of each function, you can chain as many functions as you want regardless of what they are.
Now the question is a bit bizarre, so indeed an explanation of why you're asking that would be welcome.
edit, following your comment
Come on, you're studying for a PhD, engage your brain!. Of course you get an error, you're trying to pass both input arguments to squeeze. Assuming it's the image you want to squeeze (why?) then:
imtranslate(squeeze(im), translation_vector)

5 Comments

I'd please you to show more respect to my questions, Guillaume. Noone forces you to respond. If you don't like the way I respond you just can go answer other user's queries. I'd appreciate to have better manners.
There is no lack of respect in my answer. The error you got is trivial to solve and I'd expect somebody undetaking a PhD to be able to understand it. That's what we teach PhDs: critical thinking (well at least, we try).
Anyway, to save us us both frustration, I will ignore your questions from now on.
@Stelios: Guillaume has spent the time to post a solution (+1). I suggest, to grab all the help you can get from the forum, but not to take it personally. In my cultural background "come on, engage your brain" would be considered to be encouraging, not as an offense.
@Guillaume. Your answering feedback seems like you are frurstrating when answering to me. And again, I am telling you it's not your obligation to answer to me, if you don't want to. By saying "Come on, ... , engage your brain", shows a disrespecting to me, since, it's like you laugh because of the other's ignorance to a specific part of coding. Sorry, we can not be all experts.
@Jan. I appreciate if Guillaume spend some time to provide his feedback but to be honest, in every culture the "come on, engage your brain" sounds ironic.
But nevermind. I don't want to continue this unpleasant incident

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Asked:

on 10 Jul 2018

Community Treasure Hunt

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

Start Hunting!