簡體   English   中英

sprintf函數:不能像使用MATLAB那樣在倍頻程中工作

[英]sprintf function: not working in octave the way it does for MATLAB

我需要調用另一個使用八度.m文件作為包裝器的命令工具。 在下面的代碼中,它在“檢測器”行中給出了錯誤。 它可以在Matlab上很好地運行,但是現在我需要將其設置為八度。 Octave的文檔沒有過多討論多行sprintf。 任何人都可以共享解決方案來應對這種情況。

%s =sprintf(...
s =sscanf(...
[...
'                                                                   \n'...
'                                                                   \n'...
'Detector {                                                         \n'...    
'   [Plane: a_x(%f,%f,%f) a_y(%f,%f,%f) center(%f,%f,%f)]           \n'...
'   x1=%f  x2=%f  nx=%d                                             \n'...
'   y1=%f  y2=%f  ny=%d                                             \n'...
'   n_x_sub=%d n_y_sub=%d                                           \n'...        
                                                                                  \n'...
'   %s                                                              \n'...    
'}                                                                  \n'...
'                                                                   \n'...
Beam                                                            \n'...  
'   start(%f,%f,%f)                                                 \n'...
'   %s                                                              \n'...
'   %s                                                              \n'...
'   %s                                                              \n'...
'}                                                                  \n'...
'                                                                   \n'...    
'Commands {                                                         \n'...
'   no_noise                                                        \n'...
'}                                                                  \n'...
],...
eu(1),eu(2),eu(3),...
ev(1),ev(2),ev(3),...
a(1)-d*ew(1),...
a(2)-d*ew(2),...
a(3)-d*ew(3),...
-(uoff+0.5)*par.du,...
(par.nu-uoff-0.5)*par.du,...
par.nu,...
-(voff+0.5)*par.dv,...
(par.nv-voff-0.5)*par.dv,...
par.nv,...
par.up,...
par.up,...
CT_scale,...
a(1),...
a(2),...
a(3),...
keV,...
kV,...
mAs);

在GNU Octave中處理多行字符串有很多可能性。 將以下內容作為其中之一:

sprintf("                     \
This is the first line\n      \
and this is the second\n      \
The square root of %d is %d\n \
", 4, 2)

\\字符是字符串分隔符 ,每當需要在下一個腳本行中繼續該字符串時,都必須使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM