Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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