Can imtranslate and squeeze be combined to one code line?
이전 댓글 표시
Can you combine squeeze and imtranslate to one line? If so, how?
댓글 수: 4
Yash Trivedi
2018년 7월 10일
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.
Stelios Fanourakis
2018년 7월 10일
편집: Jan
2018년 7월 10일
Jan
2018년 7월 10일
@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.
Stelios Fanourakis
2018년 7월 11일
답변 (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
Stelios Fanourakis
2018년 7월 10일
Guillaume
2018년 7월 10일
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.
Jan
2018년 7월 10일
@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.
Stelios Fanourakis
2018년 7월 10일
편집: Stelios Fanourakis
2018년 7월 10일
Stelios Fanourakis
2018년 7월 10일
카테고리
도움말 센터 및 File Exchange에서 Medical Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!