Info

此问题已关闭。 请重新打开它进行编辑或回答。

what's wrong with this code?

1 次查看(过去 30 天)
Arman Kam
Arman Kam 2012-7-26
关闭: MATLAB Answer Bot 2021-8-20
Hi,i have an array named sumNy. the content of sumNy gives me Ny and the number of it's cells show me corresponding accelerations. now i have a specified Ny that is between two Ny s in my sumNy array, and i want to obtain it's corresponding acceleration.
i wrote this code but i dont know why it is not working and it gives me y=0 !
for i=1:150
if i==1
y=0;
elseif sumNy(1,i-1)<=(1/475) & sumNy(1,i)>=(1/475)
y=(((1/475)-sumNy(1,i))/(sumNy(1,i-1)-sumNy(1,i)))*(i-1)+(1-(((1/475)- sumNy(1,i))/(sumNy(1,i-1)-sumNy(1,i))))*(i);
end
end
i must say that (1/475) is my specified Ny and there is two Ny s in my array that the specified Ny (1/475) place between them, so that is not why everytime i run this code it gives me y=0 !
please help me
Thanks
  2 个评论
Arman Kam
Arman Kam 2012-7-26
编辑:Arman Kam 2012-7-26
and here is sumNy array
sumNy=0.685079623000000 0.236606832000000 0.110267992000000 0.0572110040000000 0.0313797510000000 0.0180288710000000 0.0108257410000000 0.00677154700000000 0.00439156000000000 0.00293762700000000 0.00201682500000000 0.00141492900000000 0.00101064000000000 0.000732723000000000 0.000537897000000000 0.000399040000000000 0.000298677000000000 0.000225270000000000 0.000171029000000000 0.000130600000000000 0.000100237000000000 7.73000000000000e-05 5.98000000000000e-05 4.65000000000000e-05 3.62000000000000e-05 2.84000000000000e-05 2.22000000000000e-05 1.75000000000000e-05 1.38000000000000e-05 1.09000000000000e-05 8.65000000000000e-06 6.87000000000000e-06 5.47000000000000e-06 4.36000000000000e-06 3.48000000000000e-06 2.79000000000000e-06 2.24000000000000e-06 1.80000000000000e-06 1.45000000000000e-06 1.17000000000000e-06 9.44000000000000e-07 7.64000000000000e-07 6.20000000000000e-07 5.03000000000000e-07 4.09000000000000e-07 3.33000000000000e-07 2.72000000000000e-07 2.22000000000000e-07 1.82000000000000e-07 1.49000000000000e-07 1.22000000000000e-07 1.01000000000000e-07 8.27000000000000e-08 6.82000000000000e-08 5.62000000000000e-08 4.65000000000000e-08 3.84000000000000e-08 3.18000000000000e-08 2.64000000000000e-08 2.19000000000000e-08 1.82000000000000e-08 1.52000000000000e-08 1.27000000000000e-08 1.06000000000000e-08 8.82000000000000e-09 7.38000000000000e-09 6.18000000000000e-09 5.18000000000000e-09 4.34000000000000e-09 3.65000000000000e-09 3.07000000000000e-09 2.58000000000000e-09 2.18000000000000e-09 1.84000000000000e-09 1.55000000000000e-09 1.31000000000000e-09 1.11000000000000e-09 9.39000000000000e-10 7.96000000000000e-10 6.75000000000000e-10 5.73000000000000e-10 4.87000000000000e-10 4.15000000000000e-10 3.53000000000000e-10 3.01000000000000e-10 2.57000000000000e-10 2.19000000000000e-10 1.87000000000000e-10 1.60000000000000e-10 1.37000000000000e-10 1.17000000000000e-10 1.01000000000000e-10 8.64000000000000e-11 7.42000000000000e-11 6.38000000000000e-11 5.49000000000000e-11 4.72000000000000e-11 4.07000000000000e-11 3.51000000000000e-11 3.03000000000000e-11 2.61000000000000e-11 2.26000000000000e-11 1.95000000000000e-11 1.69000000000000e-11 1.46000000000000e-11 1.27000000000000e-11 1.10000000000000e-11 9.52000000000000e-12 8.27000000000000e-12 7.18000000000000e-12 6.25000000000000e-12 5.43000000000000e-12 4.73000000000000e-12 4.12000000000000e-12 3.59000000000000e-12 3.13000000000000e-12 2.73000000000000e-12 2.39000000000000e-12 2.08000000000000e-12 1.82000000000000e-12 1.59000000000000e-12 1.40000000000000e-12 1.22000000000000e-12 1.07000000000000e-12 9.39000000000000e-13 8.24000000000000e-13 7.23000000000000e-13 6.35000000000000e-13 5.58000000000000e-13 4.91000000000000e-13 4.32000000000000e-13 3.80000000000000e-13 3.35000000000000e-13 2.95000000000000e-13 2.60000000000000e-13 2.29000000000000e-13 2.02000000000000e-13 1.79000000000000e-13 1.58000000000000e-13 1.39000000000000e-13 1.23000000000000e-13 1.09000000000000e-13 9.65000000000000e-14 8.54000000000000e-14 7.57000000000000e-14 6.71000000000000e-14 5.95000000000000e-14 5.28000000000000e-14 4.68000000000000e-14 4.16000000000000e-14
Arman Kam
Arman Kam 2012-7-26
one can see (1/475) is between 10th and 11th value.

回答(1 个)

Arman Kam
Arman Kam 2012-7-26
sorry friends, i just find out my horrible mistake!
but still if you have a better way to do this please tell me

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by