Unable to perform assignment because the left and right sides have a different number of elements.
이전 댓글 표시
I am trying to plot w, Pc, and F as functions of time following an iterative process but keep getting this error. How do I make them have the same number of elements?
clear all
close all
clc
hold on
for T = 1:1:101
t = (T-1)/5;
w(T) = 0.514 .* t; % Web Distance
Ab(T) = (2 .* pi) .* (((144-(3 + w).^2)) + ((3 + w) .* 20) + ((144-(3 + w).^2))) % Burn Area
Pc(T) = (1088000 .* Ab ./ (400000000 .* pi)).^(1/0.7); % Chamber Pressure
rb(T) = 0.4 .* Pc.^0.3; % Burn Radius
F(T) = Pc .* pi .* 8000000; % Thrust Force
if w > 9
break
else
continue
end
end
plot(w);
xlim([0 90])
ylim([0 10])
title('Web Distance vs. Time')
xlabel('Time (s)')
ylabel('Web Distance')
plot(Pc);
xlim([0 90])
ylim([0 5])
title('Chamber Pressure vs. Time')
xlabel('Time (s)')
ylabel('Chamber Pressure')
plot(F);
xlim([0 90])
ylim([0 10])
title('Thrust vs. Time')
xlabel('Time (s)')
ylabel('Thrust')
hold off
댓글 수: 3
DGM
2022년 2월 22일
On the second pass, w is a vector. The RHS of that assignment is a vector. The LHS is a scalar. If you're trying to use a specific element of w (e.g. w(T-1)), you'll have to make that change.
Student
2022년 2월 22일
DGM
2022년 2월 22일
It's up to you to decide which elements you're trying to use. Decide which one you want and specify the appropriate index instead of the entire vector.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!