How do I square an array?
75 次查看(过去 30 天)
显示 更早的评论
Hi, I'm trying to square an array, but it won't work for some reason, and I cannot figure out why. I'm sure I'm probably overlooking something big though.
x=[a:10:b];
y=x.^2;
gz=-0.2794*(p)*(r^3)*z/((y+z^2)^(3/2))
It gives me multiple errors whenever I try to run this code through, even though I coded all of the variables, it doesn't like trying to square them.
1 个评论
回答(2 个)
Image Analyst
2022-8-29
编辑:Image Analyst
2022-8-29
This works fine for me
% Define parameters
a = 10;
b = 40;
x=[a:10:b]
y=x.^2
% Define parameters
p = 2;
r = 3;
z = 6;
gz=-0.2794*(p)*(r^3)*z ./ ((y+z.^2) .^ (3/2))
If you have any more questions, then attach your actual error message (ALL the red text) and data (actual parameters) and code to read it in with the paperclip icon after you read this:
0 个评论
Nisarg
2024-5-8
class_intervals = [10, 20, 30, 40, 50];
frequencies = [5, 8, 12, 10, 6];
n = sum(frequencies)
mean = sum(class_intervals .* frequencies)/n
y = sum(frequencies.*((class_intervals - mean).^2))
std = sqrt(y/n)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!