Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help with MATLAB code; discrepancy between graph max and Matlab's max

Tags:
  1. Feb 15, 2014 #1
    Hi,

    For some reason, when I run this MATLAB code, I'm getting what looks like about 10,000 for Rf for the largest Vo on the graph, but matlab is giving me Rf at (Vo)max as 100,001

    Any ideas?

    clc;
    clear;
    close all;

    syms Rf

    Rf = 0:0.1:100000;

    VRt25 = 18.*(10000)./(10000 + Rf);
    VRf25 = 18.*(Rf)./(10000 + Rf);

    VRt2505 = 18.*(9977.81)./(9977.81 + Rf);
    VRf2505 = 18.*(Rf)./(9977.81 + Rf);

    V_difference25 = abs(VRt25 - VRf25);

    V_difference2505 = abs(VRt2505 - VRf2505);

    Vo_difference = abs(V_difference25 - V_difference2505);

    figure;
    plot(Rf,Vo_difference)
    title('Voltage Difference Vo vs. Rf')
    ylabel('Vo Difference [V]')
    xlabel('Rf [ohms]')
    hold on

    %Maximum Vo Difference
    [Vo_difference_max,Rf] = max(Vo_difference)
     
  2. jcsd
  3. Feb 20, 2014 #2

    kreil

    User Avatar
    Gold Member

    There is no issue here.

    Rf has 1,000,001 elements, as does Vo_difference.

    The maximum of Vo_difference is 0.02, occurring at index 100,001. This means Vo_difference(100001) = 0.02.

    The part you missed is that Rf(100001) = 10000 as expected. That is, the Rf you printed with max() gives you an index _into_ the original Rf, not a direct value of Rf.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Help with MATLAB code; discrepancy between graph max and Matlab's max
  1. Matlab Coding Help ! (Replies: 3)

  2. Matlab code help (Replies: 5)

Loading...