--When I run this code it gives me a rank deficient error for both sections of the question.--
The code and question is included in the body. Thanks for responses.
%% 5
clear, clc
%For a particular circuit that drives two warning bulbs to flash, use the
%following values: Resistance for time constant: R Ranges from
%100k? through 600k? (create 6 values of R (Don’t forget to convert to ?)
%Combined resistance of the bulbs: RL Ranges from 10k? through 50k?
%(create 5 values of RL)
%Capacitor: C 10µF (µ = 10-6) Don’t forget to convert to F
%Voltage at which bulbs turn on: Von 4 V
%Voltage at which bulbs turn off: Voff 1 V
%Voltage of the power source: VS 6V
%Thevenin voltage:
%Time until bulb turns on:
%Time until bulb turns off:
clear, clc
R = linspace(100000,600000,6)
Rl = linspace(10000,50000,5)
C = 10 * 1e-6
Von = 4
Voff = 1
Vs = 6
%a) Use the meshgrid function to compute the behavior of the circuit for
%the two ranges of resistances (R and RL) provided above. Looking at your
%results, how do ton and toff depend on R and RL? Describe how you could
%modify the above circuit to have any ton or toff that you would desire.
%Note: a result of a negative or imaginary value for toff means that the
%bulb never turns off.
[new_R, new_Rl] = meshgrid(R,Rl)
Vth = ((new_Rl .* Vs)./(new_R + new_Rl))
Ton = new_R .* C .* log((Voff - Vs)/(Von - Vs))
Toff = ((new_R .* new_Rl .* C)/(new_R + new_Rl)) * log((Von - Vth)/(Voff - Vth))
%b) Suppose the power supply was changed to 9V. Repeat the calculations
%in part a and describe the effect on ton and toff.
Vs = 9
Vth1 = ((new_Rl .* Vs)./(new_R + new_Rl))
Ton1 = new_R .* C .* log((Voff - Vs)/(Von - Vs))
Toff1 = ((new_R .* new_Rl .* C)/(new_R + new_Rl)) * log((Von - Vth)/(Voff - Vth))

Réponses (1)

Star Strider
Star Strider le 9 Sep 2019

0 votes

Since I assume that you want to do element-wise operations, not matrix division, in the ‘Toff’ calculation, remember to do element-wise division as well.
Try this:
Toff = ((new_R .* new_Rl .* C)./(new_R + new_Rl)) .* log((Von - Vth)./(Voff - Vth))

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by