[Matlab] Ideal Diode (Vector Graph)?

In summary, the conversation is about a novice struggling with an introductory engineering problem solving course using Matlab. The person has provided a screenshot of their code and is looking for help to fix an issue with the plot appearing blank or as a straight horizontal line. The expert suggests checking the code for errors and making sure the correct variables are being used. They also mention that the code for setting vL to 0 should be vL(k)=0 instead of vL=0 to avoid setting the whole vector to 0.
  • #1
qwrax
1
0
Hello, I am a novice in an introductory engineering problem solving course using matlab, and I'm having a bit of a problem.
I have attached a screenshot. I know this is supposed to be pretty basic stuff, But I am hung up on it.


Now, what I have so far:


t=(0:0.01:10);
vs=3*exp(-t/3).*(sin(pi*t));

for k=1:1:length(t);

if vs(k) > 0;
vs(k)=vL;

else vs(k)<= 0;
vL=0;

end
end



disp(vL)
plot(t,vL)
xlabel('Seconds')
ylabel('Voltage')
title('Problem 2(Part A)')

Obviously I am doing something very wrong, as when it plots, I get nothing, the graph appears blank, or is a straight horizontal line at (0,0) or something. I am having trouble narrowing it down, I think the problem lies within the % for k=1:1:length(t), and the %else, or maybe I am simply doing everything wrong to begin with.

If anyone could shed a little light, or give a nudge in the correct direction, I would be greatly appreciative. I have also attached for what the graph is supposed to look like.
 

Attachments

  • Capture.PNG
    Capture.PNG
    22.3 KB · Views: 861
  • graph.PNG
    graph.PNG
    1.4 KB · Views: 724
Last edited:
Physics news on Phys.org
  • #2
I think you keep getting Vs and VL confused

if vs(k) > 0;
vs(k)=vL;

shouldn't it be vL(k)=vs(k)?

Also, vL=0 will set the whole vector to zero; I think you mean vL(k)=0;
 

1. What is an ideal diode in Matlab?

An ideal diode in Matlab is a mathematical model used to simulate the behavior of a real diode in a circuit. It is assumed to have zero resistance when forward biased and infinite resistance when reverse biased, making it an ideal switch for rectifying current.

2. How do I create a vector graph of an ideal diode in Matlab?

To create a vector graph of an ideal diode in Matlab, you can use the "plot" function to plot the current-voltage relationship of the diode. This can be done by defining the diode's ideal characteristics (zero resistance when forward biased and infinite resistance when reverse biased) and plotting the resulting curve.

3. Can I simulate the behavior of an ideal diode in a circuit using Matlab?

Yes, you can simulate the behavior of an ideal diode in a circuit using Matlab. This can be done by incorporating the ideal diode model into your circuit simulation and analyzing the resulting current and voltage values.

4. How can I use an ideal diode in Matlab to analyze the rectifying behavior of a circuit?

To analyze the rectifying behavior of a circuit using an ideal diode in Matlab, you can plot the diode's current-voltage relationship and observe the resulting curve. This will show you how the diode behaves when the circuit is forward or reverse biased, and can help you understand the rectifying behavior of the circuit.

5. Are there any limitations to using an ideal diode model in Matlab?

Yes, there are limitations to using an ideal diode model in Matlab. This model assumes ideal characteristics, which may not accurately reflect the behavior of a real diode in a circuit. It also does not take into account temperature effects, which can impact the performance of a diode. Therefore, it is important to use this model with caution and validate the results with real-world measurements.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
572
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
8K
Back
Top