Resulting bogus values when changing loop range
2 views (last 30 days)
Show older comments
The code below loops through an excel file. An example excel file data is as follows 10 0.22 10 0.22 10 0.22 5 0.23 10 0.24 10 0.24 5 0.25 10 0.29
The code loops through starting from 0.22 and if it finds the same second column number then it adds the first column. My code works but as soon as I change the width variable from width = 0.22:0.01:0.29 to 0.22:0.01:0.4 it doesnt calculate some length and returns bogus value 0. I am trying to figure out why so. Any hep would be greatly appreciated. Changing the range for width gives bogus values.
clear
clc
filename = 'C:\Users\vvangapally\Documents\MATLAB\ReadoutSeg.xlsx';
A = xlsread(filename);
%format LONGENG
% Assign Wire_Length to the first column
Wire_length = A(:,1);
% Assign Wire_width to the second column
Wire_width = A(:,2);
% Assign chip area, it changes depending upon the size of the layout you
% are measuring
chip_area = 3600 * 1600;
% width is the spacing function you used to create the dataset
%width = 0.22:0.01:50;
width = 0.22:0.01:0.32;
width = width';
% ntot is the total number of widths
ntot = length(width);
% Assigning length and fraction_of_chip_Area matrices to be all zeros
len = zeros(ntot,1);
%len = cell(ntot,1);
%len = 0;
%fraction_of_chip_area = 0;
fraction_of_chip_area = zeros(ntot,1);
% Loop function to add all the length in one met-to-met spacing else retain
% the original value
for j = 1:length(Wire_width)
for i = 1:ntot
if Wire_width(j,1) == width(i,1)
len(i,1) = len(i,1) + Wire_length(j,1) ;
else
len(i,1) = len(i,1);
end
fraction_of_chip_area(i,1) = ((len(i,1)*width(i,1))/chip_area)*100 ;
end
end
%fraction_of_chip_area = (len * width) / chip_area ;
bar(width, fraction_of_chip_area)
xlabel('Metal to Metal Spacing in um')
ylabel('Fraction of Chip Area (%)')
title('Metal to Metal Spacing vs Fraction of Chip Area')
%hist(fraction_of_chip_area)
0 Comments
Answers (0)
See Also
Categories
Find more on Logical 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!