I have a set of summer tires that are 225/40R18 90Y. Can I replace my 225/40 tires with either the 225/45 or 235/50?
You want to keep the rolling circumference consistent, so your speedo doesn't get knocked out of calibration. Have you currently measured what your speedo reads relative to GPS? What is the OEM tyre size?
Using a tyre circumference calculator, the following are the results for the sizes you suggested:
225/40 R18: 2002mm 225/45 R18: 2073mm (+3%) 225/50 R18: 2141mm (+7%)
This means that if your car is expecting 225/40 R18 tyres, you will be doing 103 or 107km/h when your car is saying 100km/h (if it's currently spot on).
I understand why you want a bigger sidewall - just make sure you're not going outside the tolerance accepted by your speedometer. Also, the easiest way to get a much bigger sidewall would be to go down to 17" alloys and 205/50 R17 tyres - this will be more economical and more comfortable.
225/40 = 25.1" in height and 225/50 = 26.9 in height. The difference there will throw off your speedometer reading. Check https://tiresize.com/height-chart/ to find a size closer to the one your car needs to insure proper speedo reading. Also, if we're talking new car here, radically changing sizes might void your warranty!