How to repeat the graph many times using FOR loop
이전 댓글 표시
Hello guys, i want to put a FOR loop in my code to plot my signal as much as i want but i still cant make it
my code below :
clc;
clear all;
close all;
%% Declaration of initial variables
fs = 5000; % Sampling Frequency in Hz
t1 = linspace(0,2000,fs) ; % Period in ms
f = 50; % Frequency in Hz
U1=230; % Supply voltage
FontSize = 10;
%% For VOLTAGE
MyVoltage = U1*sin(2*pi*f*t1); % Sine wave generation
subplot(5,1,1);
plot(t1,MyVoltage)
grid on;
xlabel('My Voltage', 'FontSize', FontSize)
ylabel('Tension (V)', 'FontSize', FontSize)
title ('Generation of voltage dips of 70%', 'FontSize', FontSize);
%% Declaration of initial variables
fs = 5000; % Sampling Frequency in Hz
t2 = linspace(2000,2500,fs) ; % Period in ms
f = 50; % Frequency in Hz
P=0.7; % disturbance percentage
U2=230*P; % Perturbation
%% For PERTURBATION
MyPerturbation = U2*sin(2*pi*f*t2); % Sine wave generation
subplot(5,1,2);
plot(t2,MyPerturbation)
grid on;
xlabel('My Perturbation', 'FontSize', FontSize)
ylabel('Tension (V)', 'FontSize', FontSize)
%% For VOLTAGE DIPS
signal = MyVoltage+MyPerturbation; % Voltage dips generation
subplot(5,1,3);
plot(t1,MyVoltage, 'r', t2, MyPerturbation, 'b')
hold on
grid on;
xlabel( 'My Voltage Dip', 'FontSize', FontSize)
ylabel('Voltage (V)', 'FontSize', FontSize)
%% Declaration of initial variables
fs = 5000; % Sampling Frequency in Hz
t3 = linspace(2500,3500,fs) ; % Period in ms
f = 50; % Frequency in Hz
U1=230; % Supply voltage
FontSize = 10;
%% For VOLTAGE
MyVoltage = U1*sin(2*pi*f*t3); % Sine wave generation
subplot(5,1,4);
plot(t3,MyVoltage)
grid on;
xlabel('My Voltage', 'FontSize', FontSize)
ylabel('Tension (V)', 'FontSize', FontSize)
%% For FINAL VOLTAGE DIPS
signal = MyVoltage+MyPerturbation; % Voltage dips generation
subplot(5,1,5);
plot(t1,MyVoltage, 'r', t2, MyPerturbation, 'b', t3, MyVoltage, 'g')
hold on
grid on;
xlabel( 'My Voltage Dip', 'FontSize', FontSize)
ylabel('Voltage (V)', 'FontSize', FontSize)
In fact i want to plot the last signal many times using a FOR loop. I tried many times but i couldnt make ...
댓글 수: 3
dpb
2022년 6월 2일
Way too little explanation of what this means, specifically -- what would be the point of plotting the same thing over and over, anyway?
Going to have to provide an actual explanation of just what you're trying to accomplish first...or show us what you did try to add and where it went wrong in terms of not producing expect result. Of course, we need to know what that expected result would be.
azerty and qwerty
2022년 6월 2일
azerty and qwerty
2022년 6월 2일
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


