write a formula for excel

3 visualizzazioni (ultimi 30 giorni)
hossein
hossein il 4 Set 2014
Risposto: Geoff Hayes il 4 Set 2014
hi I want to write a long formula in excel like this: if(A1=$C1,1,if(A1=0,0,-.33))+if(A2=$C2,1,if(A2=0,0,-.33))+ ... for 1 to 100 to avoid copy and paste 100times I write a code in matlab but it error I wrote:
for i=1:100 display('if(Ai=$Ci,1,if(Ai=0,0,-.33))+') end how to change my code to write formula correctly?

Risposta accettata

Geoff Hayes
Geoff Hayes il 4 Set 2014
Hossein - just use fprintf
for k=1:100
fprintf('if(A%d=$C%d,1,if(A%d=0,0,-.33))+',k,k,k);
end
The above will write a single line to the Command Window with all the if statements. If you want each statement on a separate line, just add \n to the end of the string
fprintf('if(A%d=$C%d,1,if(A%d=0,0,-.33))+\n',k,k,k);

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by