Plotting arrays with different sizes
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to plot a function where the arrays are different sizes
gamma = [1, 1.2, 1.4, 1.6, 1.8, 2];
x = [0:0.01:2000];
b = 349.22567;
y = 2.*(gamma.^2 - x./b);
How can I do this? Obviously
arrays have incopatible sizes
so this will not work. It would be unwise at best to do
plot(x, 2.*(gamma(1)^2 - x./b), 'b')
% etc...
댓글 수: 0
채택된 답변
Star Strider
2023년 5월 26일
편집: Star Strider
2023년 5월 26일
Transpose ‘gamma’ to create a family of curves —
gamma = [1, 1.2, 1.4, 1.6, 1.8, 2];
x = [0:0.01:2000];
b = 349.22567;
y = 2.*(gamma(:).^2 - x./b)
figure
plot(x, y)
grid
xlabel('X')
ylabel('Y')
legend("\gamma = "+string(gamma(:)), 'Location','best')
A slightly different version —
gamma = [1, 1.2, 1.4, 1.6, 1.8, 2].';
x = [0:0.01:2000];
b = 349.22567;
y = 2.*(gamma.^2 - x./b)
figure
plot(x, y)
grid
xlabel('X')
ylabel('Y')
legend("\gamma = "+string(gamma), 'Location','best')
.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Gamma Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!