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

2 views (last 30 days)
% 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)

KSSV
KSSV on 25 Nov 2022
% 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)')

VBBV
VBBV on 25 Nov 2022
You can transpose the output of ode23 as follows
y(j,:)= [i, x(:,1).']; % transpose col matrix
plot(y,'r.'); drawnow
  1 Comment
VBBV
VBBV on 25 Nov 2022
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

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!