Verfasst am: 03.12.2010, 17:36
Titel: Mehrere Plots in einem Subplot?
Hi,
ich habe folgendes Problem und zwar würde ich gerne mehrere Plots in einem Subplot unterbringen, bekomme das aber auf 'herkömmliche' Weise nicht hin.
Zu Beginn berechne ich einen zeitabhängigen Strom ie, den ich mir an gegebener Stelle im ersten von zwei Subplots darstellen lasse und anschließend einen Spannungsverlauf Vm, der im zweiten Subplot dargestellt wir. Im weiteren Verlauf des Programms werden noch zwei Ströme ic und ir bzw. eine Spannung Vinfty mit der selben Zeitskalierung wie die beiden ersten Ergebnisse berechnet. Diese neuen Ergebnisse würde ich nun gerne in die bereits bestehenden Subplots integrieren, habe aber jedes mal das Problem, das jeweils nur der letzte Plot angezeigt wird und die vorherigen Verläufe 'gelöscht' werden.
Ist es prinzipiell nicht möglich mehrere Plots nacheinander in einem Subplot unterzubringen, oder muss ich beim Erzeugen des Subplots etwas spezielles berücksichtigen?
Code:
% 2. Define parameters (rm, cm, i0, taum).
i0 = 25; % amplitude of electrode current, in nA/mm2
rm = 0.9; % 0.9 MOhm*mm^2
cm = 12; % 12 nF/mm^2
taum = rm*cm;
Vm(1) = 0; % first entry in vector for membrane Potential, mV
% 3. Define time vector (dt, T, t).
dt = 0.05; % time step 0.05 ms
T = 250; % total time 250 ms
t = 0:dt:T; % time vector
% 4. Generate your own input current vector.
ix1 = round(length(t)/3);
ix2 = round(2*length(t)/3);
% 5. Plot the current into the first axis figure;
hold on
subplot(2,1,1); % a 2x1 matrix of axes, plot into the first one plot(t,ie,'r'); % red is a nice color xlabel('time [ms]');
ylabel('Current [nA]');
% 6. Iteratively calculate membrane potential and capacitor current for i=1:length(t)-1% Why -1?
Vinfty(i) = rm * ie(i);
% Compute dV, the change in membrane potential at time i.
dV = (Vinfty(i) - Vm(i))/taum*dt;
% Compute membrane potential at time i+1.
Vm(i+1) = Vm(i)+dV;
% 7. Plot the voltage into the second axis subplot(2,1,2); % a 2x1 matrix of axes, plot into the second one plot(t,Vm,'g');
xlabel('time [ms]');
ylabel('V_{mem}[mV]');
% !!!!!!!!!!!!! Hier ist das Problem, folgender Code funktioniert NICHT!!!!! % Am Ende wir nur der letzte Plot mit ic dargestellt! % Plot the additional currents (ic, ir) into the first axis subplot(2,1,1);
plot(t,ir,'b'); % blue is a nice color plot(t,ic,'g'); % green is a nice color
% Plot the additional voltage (Vinfty) into the second axis. % ??????????????
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.