pi_c = [2 3 5 10 20 30];M_0 = 0.1:0.1:3;for i = 1:length(M_0) tau_r = 1+(gamma-1)*M_0(i)^2/2; for j = 1:length(pi_c) tau_c = pi_c(j)^((gamma-1)/gamma); tau_t = 1-(tau_r/tau_lambda)*(tau_c-1); S_2 = c_p*T_0*g_c*(tau_lambda-tau_r*tau_c)./(a_0*h_PR*... (sqrt(2*tau_lambda*(tau_r*tau_c*tau_t-1)/... ((gamma-1)*tau_r*tau_c))-M_0)); S_2_vec(i,j) = S_2*10^6; end end
When I run the program I get this error:
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in HW4 (line 120)
S_2_vec(i,j) = S_2*10^6;
When I step through the program, the first time it calculates S_2, it instantly forms a 1×30 matrix, rather than just calculating one value for that iteration.
Any help would be greatly appreciated.
All the variables are shown below, the only 1×30 matrix is M_0
Best Answer