how to create 1*101 of some integer array?
Show older comments
Hi,
Very basic que: I would like to have 1*101 of -4 array. I have to solve an integral numerically
int_0^x -4 dx;
My code is like:
x= linspace(0,1,0.01);
A = zeros(1,101);
..
cumtrapz(x,-4*A);
But the command prompt shows all zeros for cumtrapz which is certainly not.
If I just use :
cumtrapz(x,-4);
it says matrix dimensions must agree. How can I create this array?
Accepted Answer
More Answers (1)
Image Analyst
on 5 Apr 2015
The third argument of linspace is the number of elements, not the increment between elements. Try this:
numberOfElements = 101; % Whatever you want
x= linspace(0, 1, numberOfElements);
A = zeros(1, numberOfElements);
Categories
Find more on Numerical Integration and Differentiation 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!