My for loop is not executing. Atleast that's what I think becoz its not returning any value. What seems to be the problem?
1 回表示 (過去 30 日間)
古いコメントを表示
Anuradha Bhattacharya
2016 年 9 月 27 日
コメント済み: Walter Roberson
2016 年 9 月 27 日
a = load('ra1.dat');
x = a(:,1);
y = a(:,2);
hold on
plot(x,y)';
for i=1:1950;
a(((y(i+50)-y(i))/(x(i+50)-x(i)))>10);
end
1 件のコメント
KSSV
2016 年 9 月 27 日
編集済み: dpb
2016 年 9 月 27 日
Dear friend
What you want to do actually? You read data from ra1.dat file and plotted x,y..then you ran a for loop..what for you wanted this loop? Does it throw any error? If not, it will show nothing as you have terminated the result. You are not using the data in the loop any where. what is the use of this loop?
採用された回答
Steven Lord
2016 年 9 月 27 日
The line inside the loop:
a(((y(i+50)-y(i))/(x(i+50)-x(i)))>10);
extracts a piece of the array a and then essentially throws away the extracted piece. It's like you were in the soup aisle at your local grocery store. You may have picked up a can of chicken noodle soup to look at it, but you put it back on the shelf. When you get to the register to buy your groceries, there won't be anything in your shopping cart.
Add code inside your for loop that actually does something with the extracted piece of the array -- put it in your shopping cart, hand it to another shopper, start juggling it (actually, the employees of the store probably wouldn't like it if you did that last action.) If you're not sure how to do something with that piece of the array, describe what you want to do and the readers may offer some guidance. We know lots of MATLAB noodle soup recipes (with L-shaped membrane noodles, naturally :)
1 件のコメント
Walter Roberson
2016 年 9 月 27 日
Steven: I have 8 food processors; why isn't my noodle soup ready in 1/8th of the time?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!