How do I stop getting extra zeros from a for loop?
1 view (last 30 days)
Show older comments
Y=1.4
P3=113.15
vs_3=1.6884
c34= P3*(vs_3)^Y;
p34=zeros(size(1.69:+0.1:1.99));
for ve34= 1.69:+0.1:1.99
i=i+1;
p34(i)= c34./((ve34.^Y));
end
When running the for loop the p34 term retruns a 1x18 martix with mostly zeros with the intended restuls at the end. It should result in a 1x4 matrix with no zeros, but I keep getting these exra zeros. Does anyone know a way to fix this?
For some reason a different error "array indicies must be positive integers or logical values " occurs when run on 2022a compared to 2019a (what I have installed), which does not show that error when run on 2019a.
0 Comments
Answers (1)
See Also
Categories
Find more on Matrix Indexing 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!