write a formula for excel
6 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Geoff Hayes
on 4 Sep 2014
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);
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!