how to solve error using horzcat dimensions of array being concatenated are not consistent

% running function_simulasi
clear
clc
x0 = 0.02; %g/L
tspan = (0:2:80);
[t, x]=ode23('function_simulasi',tspan,x0);
j= 1;
for i = 0:1:80
y(j)= [i, x];
plot(y(:),'r.'); drawnow
j=j+1;
end
title('Konsenterasi Biomassa terhadap waktu')
xlabel('Waktu reaksi (jam)')
ylabel('Konsenterasi (g/L)')
the problem that is in the line : y(j)= [i, x];
can anyone explain?

Answers (2)

% running function_simulasi
clear
clc
x0 = 0.02; %g/L
tspan = (0:2:80);
[t, x]=ode23('function_simulasi',tspan,x0);
plot(t,x(:,1))
title('Konsenterasi Biomassa terhadap waktu')
xlabel('Waktu reaksi (jam)')
ylabel('Konsenterasi (g/L)')
You can transpose the output of ode23 as follows
y(j,:)= [i, x(:,1).']; % transpose col matrix
plot(y,'r.'); drawnow

1 Comment

y(j,:)= [ones(1,length(x)).'*i, x]; % transpose col matrix
plot(y(:,1),y(:,2:end),'r.'); drawnow
alternately you can try this too

Sign in to comment.

Categories

Products

Release

R2021a

Asked:

on 25 Nov 2022

Commented:

on 25 Nov 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!