0

I have a function:

int = input("Introduce the intensity: ")
wave = input("Introduce the wavelength: ");
e = input("Introduce e: ");
function [brighttemp] = brightness_temp_function(int, wave, e)
   A = 1.19 .* (10 .^ 8);
   B = 1.441 .* (10 .^ 4);
   brighttemp = sprintf("%.2f",(B ./ (wave .* (log (1 .+ ((e .* A) ./ (int .* (power(wave,5)))))))) .- 273.15);
   disp(brighttemp);
endfunction
[brighttemp] = brightness_temp_function(wave, e, int);`

When I enter a single value for each variable, it outputs a single answer for brighttemp. But when I enter in a vector for one of the variables, such as [8, 9; 7, 8.5] for the int variable and single values for the others, I get back an output like this for brighttemp: 20.727.812.924.3 instead of a vector similar in format to the vector inputted for the int variable, like this [20.7, 27.8; 12.9, 24.3] . What do I have to do to get an output like the latter vector?

itsduo
  • 1
  • 2
  • The easy way is to use [`mat2str`](https://octave.sourceforge.io/octave/function/mat2str.html). – beaker Jul 14 '21 at 15:08
  • Have you tried not using the `sprintf` function? If you write your 7th line as just `brighttemp = (B ./ (wave .* (log (1 .+ ((e .* A) ./ (int .* (power(wave,5)))))))) .- 273.15;` then it should work. – Howard Rudd Jul 17 '21 at 10:37

0 Answers0