Invalide value : Nan in Pie chart - anylogic

How can I avoid getting the error "Invalid value:NaN"?
I have created a Pie Chart and the values are the result of a division. I only want the chart to create if the result is not a NaN, otherwise that value should be set to zero!
Can I do this in the properties of the chart itself?
I tried writing something like: try-catch.
But it tells me that the value must be a double

you can use the function zidz(x,y) that generates the division x/y and if the division in invalid (NaN or infinity), the result is 0

Related

Is it possible to convert categorical measures to numerical measures in Tableau?

I am attempting to use the ZN() function to detect any NULL values, but the measures I need to use are categorical.
They can either only hold one of two values (Valid or Invalid) or be blank.
Is it possible for Tableau to treat these categorical values as numerical?
My first thought was to use a factorisation-type function, like the one in R, but I am not aware of any such function in Tableau.
Can this be achieved?
Create calculated field with following formula
CASE [YOUR_FIELD]
WHEN NULL THEN 0
WHEN 'Invalid' THEN 1
ELSE 2 END

Finding standard deviation of an image

Firstly, I want to find standard deviation of this image:
Secondly, I want to find standard deviation of all lines in the image.
But at the first step, somethings going wrong and I see this:
>> A = imread('C:\Users\PC\Desktop\deneme.jpg');
>> std (A);
Error using var (line 65)
First argument must be single or double.
Error in std (line 38)
y = sqrt(var(varargin{:}));
line 65: error(message('MATLAB:var:integerClass'));
line 38: y = sqrt(var(varargin{:}));
How can I solve this problem and what is the code of finding standard deviation of all lines in this image?
The error is very explicit:
First input argument must be single or double.
This happens because A is of type uint8. The input to std has to be floating point (single or double).
So: convert to double, and optionally divide by 255 to normalize values to the interval between 0 and 1:
std(double(A)/255)
Note that the above gives the standard deviation of each column. If you want the stantard deviation of the image considered as a whole, linearize to a column vector first:
std(double(A(:))/255)

fplot: anonymous function returns only zeros if limits not in specific range

I have a csv-file with some integers stored in three columns
trainData = load('training.csv')
I want to count the occurences of a certain value within a certain range and plot the results.
count = #(x) (sum(trainData(:,2)==x));
fplot(count,[0,500]);
However this only works for certain limits and I can't figure out why. If the limits are not set "right", count() always returns zero.
this works, meaning the plot shows some values > 0:
fplot(count,[0,500]);
fplot(count,[100,600]);
fplot(count,[101, 601]);
fplot(count,[200,700]);
fplot(count,[50, 550]);
The plot of [0,500]:
This does not, meaning the line stays flat, even though there are definitely some y > 0 within this range (compare to previous plot):
fplot(count,[0,300]);
fplot(count,[200,450]);
fplot(count,[1,501]);
The plot of [200, 450], oddly the value for f(250) is 1 and the rest is 0 :
The reason for this strange behaviour was fplot's way of picking values from the specified range of x-values. By default the step size is not 1 (which I assumed), nor does fplot use all possible values within the specified range (which would be probably impossible). Therefore my method did not find all values occuring in the csv (they were all integers). So the "working" examples from above did probably only hit some of the occuring values and the non-working example simply the starting value (plot of [200,450]), but not any other.
Briefly speaking, following solves the problem:
fplot(count,[0,n], n);
It evaluates the anonymous function for each integer in range 0 to n.

Extract max/min values from a table in workspace in Matlab

Back to basics. How can I extract max and min values from 'variable' table in workspace? min(nameofvariable) don't work, returns an error message 'Subscript indices must either be real positive integers or logicals'.
Thanks for your help!
Assuming you have a matrix called nameofvariable, the correct syntax is indeed:
min(nameofvariable)
This will give you the column wise min
For the full minimum:
min(nameofvariable(:))
The error you have suggests that you have a variable named min (try to avoid this at all times), try:
clear min
min(nameofvariable)

How do I deterimine if a double is not infinity, -infinity or Nan in SSRS?

If got a dataset returned from SSAS where some records may be infinity or -infinity (calculated in SSAS not in the report).
I want to calculate the average of this column but ignore those records that are positive or negative infinity.
My thought is to create a calculated field that would logically do this:
= IIF(IsInfinity(Fields!ASP.Value) or IsNegativeInfinity(Fields!ASP.Value), 0 Fields!ASP.Value)
What I can't figure out is how to do the IsInfinity or IsNegativeInfinity.
Or conversely is there a way to calculate Average for a column ignoring those records?
Just stumbled across this problem and found a simple solution for determining whether a numeric field is infinity.
=iif((Fields!Amount.Value+1).Equals(Fields!Amount.Value), false,true)
I'm assuming you are using the business intelligence studio rather than the report builder tool.
Maybe you are trying a formula because you can't change the SSAS MDX query, but if you could then the infinity would likely be caused by a divide by zero. The NaN is likely caused by trying to do Maths with NULL values.
Ideally change the cube itself so that the measure is safe from divide by zero (e.g. IIF [measure] = 0,don't do the division just return "", otherwise do it) . Second option would be create a calculated measure in the MDX query that does something similar.
As for a formula, there are no IsInfinity functions so you would have to look at the value of the field and see if its 1.#IND or 1.#INF or NaN.