Fprintf and display in the same script
Mostrar comentarios más antiguos
I have to display a series of numbers, fibonacci's through 15 using both fprintf and disp functions. I have managed to get it to work but not without work arounds. I need to know is there any way to execute the program without commenting out fprintf and flipping my variable, n. Code is below
clc; clear;
n = (0:15)';
f = (1/sqrt(5)).*((((1+sqrt(5))/2).^n)-(((1-sqrt(5))/2).^n));
%fprintf(1,'F%1.0f= %1.0f\n',[n;f]) %%to make this work, I have to get rid
%of the transpose on the n variable and comment out the disp command.
disp([repmat('F',16,1) num2str(n,'%1.0f') repmat('= ',16,1) num2str(f,'%1.0f') ]); %to get this to work, I have to add in the n variable and comment out the fprintf command
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!