<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Getting error The value must be  scalar or a matrix in Mathcad</title>
    <link>https://www.ptcusercommunity.com/t5/Mathcad/Getting-error-The-value-must-be-scalar-or-a-matrix/m-p/1028953#M218322</link>
    <description>&lt;P&gt;I am getting error for programming could someone please help&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Aug 2025 10:21:20 GMT</pubDate>
    <dc:creator>JW_9781974</dc:creator>
    <dc:date>2025-08-12T10:21:20Z</dc:date>
    <item>
      <title>Getting error The value must be  scalar or a matrix</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Getting-error-The-value-must-be-scalar-or-a-matrix/m-p/1028953#M218322</link>
      <description>&lt;P&gt;I am getting error for programming could someone please help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 10:21:20 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Getting-error-The-value-must-be-scalar-or-a-matrix/m-p/1028953#M218322</guid>
      <dc:creator>JW_9781974</dc:creator>
      <dc:date>2025-08-12T10:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting error The value must be  scalar or a matrix</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Getting-error-The-value-must-be-scalar-or-a-matrix/m-p/1028965#M218323</link>
      <description>&lt;P&gt;Problem is the unit cm which you add at the end.&lt;/P&gt;
&lt;P&gt;If "Len" is larger than 2 cm your program returns the string "n/a" and you can't add a unit to a string. You can add a unit to a scalar numeric value or to a matrix of numeric values, but not to a string - hence the error message.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_0-1754996943333.png" style="width: 447px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126909i962C700CD66998EC/image-dimensions/447x496?v=v2" width="447" height="496" role="button" title="Werner_E_0-1754996943333.png" alt="Werner_E_0-1754996943333.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BTW, inline evaluation may work OK most of the time but sometimes can lead to unexpected effects.&amp;nbsp;Therefore, I have made it a habit to always separate the definition of a variable and its evaluation/display for safety reasons, as shown in the image above. This also shows clearly that it is not the program that causes the error, but the attempt to display a string with a unit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Solution depends on what you intend to do with a variable which sometimes represents a length and sometimes a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example you may replace the string by the built-in constant "NaN" ("Not-a-Number", -&amp;gt;&amp;nbsp;&lt;A href="https://support.ptc.com/help/mathcad/r11.0/en/?utm_source=mathcad/index.html#page/PTC_Mathcad_Help/about_the_nan_constant.html" target="_blank" rel="noopener"&gt;About the NaN (Not a Number) Built-In Constant&lt;/A&gt;) or even better for consistency you may add a length unit to NaN, too.&lt;/P&gt;
&lt;P&gt;If you need later to programmatically ask if "y" is a numeric quantity or a NaN you may use the boolean function "IsNaN()" because something like "if y=NaN ..." does not work.&lt;/P&gt;
&lt;P&gt;Every calculation using y when its NaN will result in NaN, too. Demonstrated below via the simple "Area" function:&lt;/P&gt;
&lt;P&gt;The "return" statement is not necessary and also the creation of a program structure (the double bar at the left) could be omitted.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Werner_E_3-1754997753035.png" style="width: 630px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126912i119C826ED94071FB/image-dimensions/630x515?v=v2" width="630" height="515" role="button" title="Werner_E_3-1754997753035.png" alt="Werner_E_3-1754997753035.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Calculation of "z" shows that you also could use the if-function (similar to the usual spreadsheet "if") instead of the programmed if-statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Prime 11 sheet attached&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 12:02:15 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Getting-error-The-value-must-be-scalar-or-a-matrix/m-p/1028965#M218323</guid>
      <dc:creator>Werner_E</dc:creator>
      <dc:date>2025-08-12T12:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting error The value must be scalar or a matrix</title>
      <link>https://www.ptcusercommunity.com/t5/Mathcad/Getting-error-The-value-must-be-scalar-or-a-matrix/m-p/1029996#M218386</link>
      <description>&lt;P&gt;Hello &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/382809"&gt;@JW_9781974&lt;/a&gt;&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you have a &lt;A href="https://community.ptc.com/t5/Mathcad/Getting-error-The-value-must-be-scalar-or-a-matrix/m-p/1028965#M218323" target="_blank"&gt;response&lt;/A&gt; from our community champion. If it helped you solve your question please mark the reply as the Accepted Solution.&amp;nbsp;&lt;BR /&gt;Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Vivek N.&lt;BR /&gt;Community Moderation Team.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2025 11:44:24 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Mathcad/Getting-error-The-value-must-be-scalar-or-a-matrix/m-p/1029996#M218386</guid>
      <dc:creator>vnamboodheri</dc:creator>
      <dc:date>2025-08-19T11:44:24Z</dc:date>
    </item>
  </channel>
</rss>

