Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6943597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:10:38+00:00 2026-05-27T13:10:38+00:00

Can somebody explain me what the following bit of code in Matlab is doing?

  • 0

Can somebody explain me what the following bit of code in Matlab is doing?

S = max(Smax/1e6,S);

Where Smax is a scalar and S is a 2d array.

In the documentation it says that: “C = max(A,B) returns an array the same size as A and B with the largest elements taken from A or B. The dimensions of A and B must match, or they may be scalar.”

But I don’t really get it. For example when I look at the data and:
Smax = 18.8919 then if the table cell = 0 it gets substituted by 1.88918608566891e-05 if the table cell = 1.26794177568026 then it gets substituted by 0.2374. Why is that happening?

Matrix before:

0   0   0   0   0   0.00111506400432957 0.0530528652679544  0.0735632798530057  0.337940336906895   0.217390264464039   0.842200681286881   0.441492820596403   0.635889579407697   0.0282173990214626  0.628686747522517
0   0   0   0   0   0.00124231354963584 0.0292268862938039  0.307854738413881   0.642250450652130   0.895774237272530   0.955937999893653   1.02416313393959    1.43102268912588    1.28612042237543    0.854476003698339
0   0   0   0   0   0.00161382073055088 0.211968938444796   1.14984433303987    1.79814921306101    1.21125341085802    0.730742783435531   0.783994053903355   2.16496222396151    1.37726874308377    0.566007297543274
0   0   0   0   0   0.00219642315401969 0.333759445110180   1.41975817872937    2.93443500804371    0.423882373725561   1.72297295599714    2.10661511095899    1.23659139050992    0.299608689818999   1.27117497124802
0   0   0   0   0   0.00293437095181858 0.170826340853254   0.505706488974208   3.09277881791955    1.01375749953753    2.72388777599623    2.14043273302288    1.97540038269762    1.36646318061577    1.31241005396504



 Matrix after:

1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05
1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    0.0238758244166261  0.358389355882494   0.251630262469816   1.88918608566891e-05
1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    0.139626570638794   0.586757920960373   0.191655700200727   1.88918608566891e-05    1.88918608566891e-05    0.772402912785602   0.320102366342357   1.88918608566891e-05
1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    0.350486560441589   1.07651493323094    1.88918608566891e-05    0.544051261541669   0.745082446545145   0.212358715890953   1.88918608566891e-05    0.239941646971664
1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.88918608566891e-05    1.12906998061232    0.0136637242376597  1.00206018919932    0.761008020284666   0.680771103223579   0.312225781724240   0.271865182822984
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:10:38+00:00Added an answer on May 27, 2026 at 1:10 pm

    First of all, it’s common practice to put the scalar variable as the second argument to the matrix, making it a bit easier to read.

    To illustrate how this should work, I’ll give you a bit of code:

    R = [0 1; 2 3];
    Smax=1;
    S=max(R,Smax)
    % At this point, S will be equal to [1 1; 2 3];
    

    What will happen is that any value below Smax will be replaced by Smax.

    In reality, this acts more like a minimum, ie, the minimum value is Smax.

    As for your specific problem, I could get more info, but I would need to see what the matrix looks like before and after the statement you provided.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody explain why the following code is not valid? Is it because the
Can somebody explain the following code please? #if 1 // loop type #define FOR_IS_FASTER
Can somebody explain me why the following piece of code fails to compile. The
can somebody explain why is the following trivial code (implementation of Euclid's algorithm to
Can somebody explain to me why the following works: template<class T> class MyTemplateClass {
Can Somebody explain me on short (just as idea) what the following fragment suggests?
Can somebody explain to me the following (python 2.7) Two string numbers, from a
can somebody explain me the difference between the following namespace usages: using namespace ::layer::module;
Can somebody explain step by step type inference in following F# program: let rec
The following example involves jumping into continuation and exiting out. Can somebody explain the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.