From: Alistair Templeton on 28 Apr 2010 13:05 While it may be unsafe programming, I seem to generate a lot of code which would be far more readable without having to explicitly refer to the handles i'm passing. I'm looking for one of the side benefits of c#'s "using" statement I suppose. An example: Instead of: handles.sqs(i) = handles.fs * 10 * handles.inf(i).RTImageSID ... / handles.inf(i).RadiationMachineSAD / handles.inf(i).ImagePlanePixelSpacing(1); Is there a command that would let me just write: handles.sqs(i) = fs * 10 * RTImageSID / RadiationMachineSAD ... / ImagePlanePixelSpacing(1); Thanks!
From: Walter Roberson on 28 Apr 2010 13:16 Alistair Templeton wrote: > While it may be unsafe programming, I seem to generate a lot of code > which would be far more readable without having to explicitly refer to > the handles i'm passing. I'm looking for one of the side benefits of > c#'s "using" statement I suppose. > > An example: > > Instead of: > > handles.sqs(i) = handles.fs * 10 * handles.inf(i).RTImageSID ... / > handles.inf(i).RadiationMachineSAD / > handles.inf(i).ImagePlanePixelSpacing(1); > > Is there a command that would let me just write: > > handles.sqs(i) = fs * 10 * RTImageSID / RadiationMachineSAD ... / > ImagePlanePixelSpacing(1); No, there no command like that in Matlab. As you are working in a loop with values extracted from the same substructure, you can do something like this: for K = 1:N thisinf = handles.inf(i); handles.sqs(i) = handles.fs * 10 * thisinf.RTImageSID / thisinf.RadiationMachineSAD / thisinfo.ImagePlanePixelSpacing(1); end You could of course shorten the temporary structure name.
From: Alistair Templeton on 28 Apr 2010 13:30 > No, there no command like that in Matlab. ahh, too bad. > As you are working in a loop with values extracted from the same > substructure, you can do something like this: > > for K = 1:N > thisinf = handles.inf(i); good point. thanks for the response!
|
Pages: 1 Prev: help with inporting from .txt file Next: Embedded matlab recursion |