How to call the element in a unknown 2-dim matrix???^_^
Show older comments
This is my first time to use the Matlab. I want to do operations on each element(the index doesn't really matter). However I don't know how to call them if I don't now the size. I should use for or while, and how? (≧∇≦) Btw, I also want to ensure , will the function return 6666 if I tap "disp(6666)"? Thanks a lot~ :)
1 Comment
James Tursa
on 9 Oct 2015
Please be more specific. Maybe give a short example showing the inputs and your desired output.
Accepted Answer
More Answers (1)
Walter Roberson
on 9 Oct 2015
x = 1 : 50;
for K = 1 : length(x)
y(K) = x(K).^3 - 10*x(K).^2 - 5;
end
y2 = x.^3 - 10*x.^2 - 5; %same result as y to within roundoff error
Categories
Find more on Creating and Concatenating Matrices 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!