How to keep result one-dimensional even after multiplication?

I am trying several functions who include vectors as variable. The variable (x) is

x= [2.0:0.5:5.0;]

I like to define the following kinds of functions:

f(x) = (x .+ 0.07im)/2.3;
g(x) = (1/f(x)).^2
h(x)  = g(x) .* (2 .- (1 .+ f(x)).^0.5 - (1 .- f(x)).^0.5)

In this case, the function h becomes 7x7 squared matrix, which I do not wish.
One dimensional vector is preferable for me. If I append [1] at the last part of h(x)
statement, I can work it around somehow.
To be honest, I prefer keeping my codes as simple as possible.
Removing “a dot before asterisk” resulted in a matrix having only one element,
which turns also out to be useless. Any idea?

While ones(3) / 3 scales the vector, the same as ./ broadcasting, y = 3 / ones(3) solves a linear system such that y * ones(3) == 3 where * means matrix multiplication. You might be looking for @., to apply all functions element-wise.

Thanks a lot. I will learn again about mapping and broadcasting. I think removing dots from function definitions and apply dot in the final calculation like h.(x). I will try it.

Yes, that is exactly the right approach. Define your functions for scalar input, and use dots when you call them. That is both cleanest and best for performance.