Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Help needed in frintf statement with if condition I have attached my code below

1 回表示 (過去 30 日間)
Rakesh Yadav Kodari
Rakesh Yadav Kodari 2019 年 5 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
if (ramps == 1)
rampChar = 0;
downChar = 0;
elseif (ramps == 2)
rampChar = 1;
downChar = 0;
end
if (ADCsamples == 1024)
disp("Configure number of samples 1024...");
fprintf(t,'%s\r\n',['!BB034 num2str(downChar) num2str(rampChar) EC']);
disp("Base Band Setup Configuration is done");
elseif (ADCsamples == 512)
disp("Configure number of samples 512...");
fprintf(t,'%s\r\n',['!BB034 num2str(downChar) num2str(rampChar) E5']);
disp("Base Band Setup Configuration is done");
end
I need the downchar and rampchar values go directly to fprintf.
but its not working.
Can anyone help please.

回答 (1 件)

Cam Jones
Cam Jones 2019 年 5 月 15 日
It looks like you have not closed out the quotes in your character arrays.
Specifically looking at
fprintf(t,'%s\r\n',['!BB034 num2str(downChar) num2str(rampChar) E5']);
There is a single quote at the start of the 3rd argument and it is not closed until the end.
When building character arrays in MATLAB, you would want to close out the raw characters before a function call.
fprintf(t,'%s\r\n',['!BB034' num2str(downChar) num2str(rampChar) 'E5']);

Community Treasure Hunt

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

Start Hunting!

Translated by