首页 > 解决方案 > 假设输入是 Octave 中的矩阵,如何将函数的输出变量的值格式化为矩阵

问题描述

我有一个功能:

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);`

当我为每个变量输入一个值时,它会为brighttemp. 但是,当我为其中一个变量输入向量时,例如变量和[8, 9; 7, 8.5]其他变量的int单个值,我会返回如下输出brighttemp: 20.727.812.924.3 而不是格式与输入向量相似的向量对于int变量,像这样[20.7, 27.8; 12.9, 24.3]。我该怎么做才能获得像后一个向量这样的输出?

标签: octaveoctave-gui

解决方案


推荐阅读