Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
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.

Antworten (1)

Cam Jones
Cam Jones am 15 Mai 2019
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']);

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by