how to input each element (different) of a matrix 'R' in same function 'f' and compute result in the matrix form?
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
- how to input each element (different) of a matrix 'R' in same function 'f' and compute result in the matrix form? *
I was trying to do this to get a series of f values in a (1x7) matrix form. Tried couple of if-loop variants, did not help. Any help is appreciated. I know this is silly, but am just very new! Thank You.
N = 7; % number of monomers % b = 1; % bond length = hypotenuse % R = rand(1, 7) f =(2 * R / (N * (b^2))) * exp(-(R^2) / (N * (b^2)))
Antworten (2)
Star Strider
am 27 Feb. 2015
You need to vectorise it.
See if this does what you want:
N = 7; % number of monomers %
b = 1; % bond length = hypotenuse %
R = rand(1, 7)
f =(2 * R ./ (N * (b^2))) .* exp(-(R.^2) ./ (N * (b^2)))
2 Kommentare
raktim roy
am 27 Feb. 2015
Star Strider
am 27 Feb. 2015
I don’t understand.
In your code, ‘f’ is simply a variable. It’s not a function. Your ‘R’ variable is a (1x7) vector, not a matrix.
What do you actually want to do?
Roger Stafford
am 27 Feb. 2015
You need dots on the last line:
f = (2 * R / (N * b^2)) .* exp(-(R.^2) / (N * b^2))
1 Kommentar
raktim roy
am 27 Feb. 2015
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!